About my recreation:
It’s written in C# MonoGame with DirectX targetting Home windows desktop. It is a turn-based recreation, max 16 gamers. Participant 1 strikes a bit, then Participant 2, and many others. Some gamers might be a pc, not human. Any given participant can finish in victory, defeat, or draw. There’s a clock like in chess, so timing must be synced, and also you lose in the event you run out of time.
About my networking wants:
I desire a matchmaking server, however as soon as a recreation begins, the purchasers themselves do all of the communication. This implies I want networking code for client-to-client (CtC) in addition to client-to-server (CtS).
I do not need customers to register with a username/password and login. Anybody with the sport app can ping the server and get a listing of video games, or arrange their very own recreation the place they’re the host, and let others be a part of.
I extremely doubt I’ll want a SQL database or SSL or net certificates. I am contemplating utilizing Node.JS or Go for the server. The shopper makes use of C# however I do not know whether or not to go together with SocketListener or TCPListener. I do not need UDP.
About my background:
Been programming for 20 years however virtually by no means any actual networking code. I do know fundamental JavaScript however virtually all the time used it as a purely client-side html file with embedded all the things, even base64-encoded sprites.
Now necessity has introduced me right here. I actually need to discover a tutorial for this type of factor, however have found that there are only a few server-coding tutorials. Virtually all search outcomes are slowed down with “arrange your minecraft server” which isn’t a code tutorial. That is an installer troubleshooter for a binary already coded by another person.
I’ve discovered some C# monogame tutorials demonstrating SocketListener and TCPListener however I am unable to get them to work proper, they all the time freeze this system apparently as a result of they’re on the principle thread? And people tutorials should not actually about networking structure and how one can deal with speaking sophisticated issues.
Issues that have to be addressed:
Can I select a single port for all the things? Can 16 purchasers and 1 server all use the identical port? (I am getting conflicting data about ports, some say its purely 2-way communication, others say it may be used for multi-cast.)
What if a participant quits a recreation in the course of it. Does the complete recreation throughout all different gamers additionally crash? Tips on how to keep away from that? And what if the host quits and its a centralized structure? How would you spawn off the sport to a brand new host?
Tips on how to deal with downloading of customized maps from the host shopper to different purchasers?
Tips on how to deal with timeouts for all types of requests, and a few fundamental DDoS safety?
How to ensure each gamers’ clock keep in sync?
A e-book advice can also be advantageous. I actually need a tutorial to handle these intermediate matters, and never simply present how one can setup a TcpListener and do a easy chat app.