Hello there,
I'm considering changing (again) all the networking tech inside a project of mine, the thing is i'm not certain if any of the approaches i took in the past are good or not, or if it is there some other approach out there which could be better than my personal approaches:
1) 2 x 2 Socket comms with TCP, using a message class to save the data and send it cleaner and safer.
- I have two sockets tcp, one for sending data to the server and one to receive it, that way more data can move between the client and the server more freely and without the need to wait for the channel to finish the last use before sending data in the other direction, that's good.
- However this approach isn't perfect because the ways to recolect data are prone to fail, with that i mean than using this approach i'm forced to feed a concurrentQueue, blockingCollection or a Queue in order to pass the instructions from the methods to the statemachine that is processing them, both clases are prone to fail when a lot of data comes.
- If anybody have any idea how to fix and maybie optimize that approach, be my guess, i tried to pass the statemachine directly from the side than receive the instructions directly from the client, but that cause the issue than i need to process the receive data in a non-response dependant way, making the comunication between the client input and what's going on need some kind of conciliation which just so happend still need a concurrentQueue, blockingCollection or a Queue.
2) See option 1 + Superclass to send big messages parted in several parts
- This kinda works but there was somewhat of a delay sometimes in some messages, however it suffers from the same (and maybie a little worse) of the issues of option 1.
3) 2x2 Socket BUT with “Dungeon Master” approach: that is, the sockets are only used for receiving client instructions and sending the answers to it, meanwhile i let a freaking gigantic Api/Rest give the status of the game on iteration cycles.
- So, this is similar to the method before but is a freaking Api/Rest, the costs are big, do you guys consider this to be the best approach for the state of the map and such? i would think it would be poorly optimized but the fact than guarantees correct transfer make it thinkable to me, i haven't went this route yet but have been consider retaking it after i found better way of serializing custom classes and to implement it in the context of having also a statemachine working in parallel.
Consider C# (.Net 6, not Unity)
Also, if you think on a better approach to async recollection of data than then one in option 1), please let me know, i may consider that as a solution to my issues.
Any observation? Recomendation? Comments or questions?
Thank you for your time