Open Ezraay opened 1 year ago
"... There are a few problems with your actual socket handling, though. The Connected property is practically useless. You should always be continuously reading from a connected socket, even while you're writing to it. Also, you should be writing "keepalive" messages or have a timeout on your reads, so that you can detect half-open situations. I maintain a TCP/IP .NET FAQ that explains these common problems.
I really, strongly recommend that people do not write TCP/IP servers or clients. There are tons of pitfalls. It would be far better to self-host WebAPI and/or SignalR, if possible."
I reckon WebAPI is our solution. In this case having server to be a standard WebApp accepting Post request and replying with data on Get's - that is looking very promising. Clients only need to know URLs - no common code between the Client and Server.
Also, DB is really easy to bolt-on later on.
I think the problem with the answer is it isn't used in context of a game. In order for the game to still be responsive to the player, TCP sockets are needed for smaller messages and headers as well as constant updates.
"You might not be able to build your game without any push-events whatsoever. There will be some cases where you want to tell the player something while they are making their moves. For example that the opponent left the game"
The common pitfalls they were talking about could be simply addressed by using a library on top of .Net sockets that solved all of those by maturity.
For instance Telepathy Super Socket
Plus common code is needed regardless, since both the client and server need to know what the battle looks like, what actions a player can do etc.
Agree about the Common code - thought about it later.
There should be an initial connection between a Client and a Server, with the ability to specify between a test-server (localhost) and production-server (x.x.x.x) when the server is finally deployed. The connection should allow the transfer of bytes with the TCP protocol. We don't need UDP since it isn't a high actions-per-minute game.