Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Network protocol definition #4

Open
elegaanz opened this issue Jun 30, 2020 · 3 comments
Open

Network protocol definition #4

elegaanz opened this issue Jun 30, 2020 · 3 comments

Comments

@elegaanz
Copy link
Contributor

We need to define a network protocol and implement it.

cc @edgarogh

@edgarogh
Copy link
Member

edgarogh commented Jul 2, 2020

I have absolutely no idea of the different "messages" needed, or where is the limit between what the clients and the server handle.

Regarding the packet framing stuff, a Packet enum with serde+bincode might be a good and fast idea if we're going with raw TCP and don't care with debug-ability and self-descriptiveness. It will make retro/forward compatibility harder though, so JSON or RON could work too.

@elegaanz
Copy link
Contributor Author

elegaanz commented Jul 2, 2020

Quick summary of what we would need:

  • a client configures a new game, and sends it to the server
  • if this game is public, the server adds it to the list of games anyone can join, and they will be displayed in some kind of "hub" in the client
  • if it is "private", you have to input a short code to join (like in the jackbox.tv games)
  • when someone join, the server should tell it to other clients
  • once everyone is in (the number of player was chosen when the game was configured), the game starts: the server sends a "start" event to all clients
  • the first player chooses a card to play, send the info to the server, which syncs it to other players. The server also checks that there is no cheating.
  • Then the second player plays, and so on, until everyone played their card for the turn.
  • The server computes who won, and send that to the clients
  • Repeat, until the end of the game. The server then computes points and sends them.

So, in summary:

  • we have a state that is shared between the server and the clients
  • because we control the server and we know we can trust it, it is responsible for checking and computing most of the things, the clients only broadcast user input and receive information from the server

Also, maybe each event should be acknowledged, to make sure all client are in sync? maYbe wE cOuLD uSe a BLoCkhAiN AnD A ConSeNSuS AlgOritHM lIKE RAfT???!! More seriously, if we have a single TCP connection for each event we send, this acknowledgement would be in TCP directly, but this seems to be a poor design to close and re-open a connection every few seconds (and it means NAT traversal or something I guess, because we are sending a request from the server to the client, so definitely: NO). Also, I don't know if TCP can be bidirectional? Like once the client sent something, can it send something else even if the server started responding in the meantime?

Ideally, there should be some kind of encryption. TLS might the be the simplest solution for that.

@edgarogh
Copy link
Member

edgarogh commented Jul 6, 2020

c.f. network branch (very much totally WIP)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants