made the join game screen to get ready for attaching to host and also made a protocol doc

This commit is contained in:
2026-02-05 15:01:44 -06:00
parent 47987ca439
commit 468ab94aa7
12 changed files with 642 additions and 334 deletions

68
net_proto.txt Normal file
View File

@@ -0,0 +1,68 @@
we will use this port in net.h
#define PORT 36911
here packet size is also defined, subject to change but makes it
easy to no block on send
#define PACKSZ 1024
pack type will be at the front of the packet to ensure we handle packets right
enum pack_type{
G_STATE, S_STATE, HOSTS_REQ, NEW_HOST, JOIN_REQ, U_NAME
};
packets are defined so that they keep the exact size of PACKSZ
typedef struct packet{
enum pack_type type;
char payload[PACKSZ - sizeof(enum pack_type)];
} packet;
JOIN GAME:
CLIENT | SERVER
HOSTS_REQ ----------->
<---------- HOSTS_REQ [ list of names that are open lobbies]
------------------------------------------------------------------------------------------
JOIN_REQ ----------->
[name of lobby, name of player]
<----------- JOIN_REQ [IP info of host with that name]
HOST GAME:
CLIENT | SERVER
NEW_HOST ------------>
[name of lobby]
<----------- NEW_HOST [ack]
(ON PLAYER JOIN REQUEST)
<------------ JOIN_REQ [player ip info]
JOIN_REQ ------------>
[lobby count]
(ON HOST START GAME)
S_STATE ----------->
[starting game]
<---------- S_STATE [ack]
(on timeout for lobbies ie games not started)
<--------- G_STATE [you alive?]
G_STATE --------->
[yup]