Skip to content

How should channels be used #81

Answered by lucaspoffo
Busin-Riccardo asked this question in Q&A
Discussion options

You must be logged in to vote

Hey,
Your guess is correct, you want to group messages that share the same configuration in an enum.
So probably having an enum for reliable messages, and another one for unreliable is good enough.

Something like

// Critical messages that should be reliable and could break game if lost (just an example)
enum ServerReliableMessage {
   PlayerAttack {
      player_id: ID,
      direction: Vec2
   },
   PlayerMoved {
      player_id: ID,
      position: Vec2
   },
   PlayerDeath {
      player_id: ID
   }
   ...
}

// Sounds/Particle Effects can be unreliable if you want (they shouldn't break gameplay if lost)
enum ServerUnreliableMessage {
   Sound {
      sound_id: ID,
      position: Vec2

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by lucaspoffo
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants