I’ve been doing a lot of research on TCP/UDP/RUDP lately and most of it is because my friend who is a Unity freak is near-completion of this MoBA(Multiplayer online Battle Arena) single-player prototype and has asked me to work on the server-side of the networking while he writes the Client-API. I told him that I was up to the challenge, mostly for a learning experience, but helping him out was definitely on my mind. I’m fairly familiar with standard IO TCP Networking, however the problem with that is the Standard IO is blocking, so I would have to study on some NIO Libraries, (Looking at you, Netty). However, some-people have stated that I would be better off using UDP/RUDP.
The problem I’ve found during my studies with UDP/RUDP is the way that messages will occur. Considering we’re going to be working on an authoritative server approach, it’s fairly important that things like movement/item activation arrive. In the order that you activate them. For instance, if a player uses an healing item, then an ability that takes 1.5 seconds to cast. If the ability is casted before the item is consumed for some reason (Typically because of UDP Packets not being ordered) it could cause death, and players screaming “Glitches, Fix them.” – This would lead me to stare at the TCP Connections; However then I would be dealing with Latency problems from my studies. However anything under 200 Latency should be fine for this type of game, and we’re not really expecting people from across the world to play without the expectation of a little lag.
So this brings me down to the question… For this particular application:
- Handles all users connected - Users not in game don’t transfer any data besides for chat, if being used.
- Players in a game (Instanced, each game will have its own game-thread) will be moving around constantly in a 2D Environment (3D world using 2 axis’)
- Ordered arrival of packets is required
- Losing Data is a Critical problem.
The only reason I’m really asking this question is because of the use of Reliable UDP which crosses out the “Losing data” issue, from my understanding, which makes this a question worth asking.