CamposDJoel / DungeonDiceMonsters

My own version of Dungeon Dice Monsters
2 stars 0 forks source link

Server <> Client Message Exchange Cleanup #152

Closed CamposDJoel closed 1 month ago

CamposDJoel commented 1 month ago

After performing a test play between the PC and the Laptop I found an issue during hovering (of course), this are my results:

-Based on the connection speed. The server could receive multiple messages from the client. The server didnt know how to handle 2 of more messages in a single string. -To fix the above, I implemented using the "$" message divider WHEN SENDING FROM CLEINT TO SERVER. Then the server will split the DATARECEIVED into multiple messages if more than 1 was received at the same time. -Once the server fowards the message to the opponent client, it add again the message divider so the client can also handle multiple messages in a singe DATARECEIVED. -Another found issue, is that during tile hovering, too many messages could be sent from client to server. I believe there is a character limit that the data stream can hold, and when too many hovering messages are sent, a single message can be cutoff it the stream is full. This causes a "choppped" message to forward it and the opposite client does not how to handle it. -To fix this above issues. I added some "Message validation" - first, a messages must contain a complete message key - so the token[0] string must start with "[" and end with "]", then, if the message key is a hovering message, validate that there is a second token that contains the tile id being handle. If no of these requirements are met, then the client will ignore the message. -"Ignoring" a hovering message does not break the execution but does causes a small glitch where the opponent play could see some highlighted tiles not being refreshed properly. But this is a minor concern if I can perform hovering without breaking the match connectivity.