5Mixer / mphx

A little library to let you make multiplayer games easily with Haxe. No longer maintained and better options are available.
MIT License
125 stars 16 forks source link

Lag - Messages are being delayed. #35

Closed 5Mixer closed 8 years ago

5Mixer commented 8 years ago

mphx seems to have a delay somewhere. It could be a general issue with the codebase or just a specific location, that hasn't really yet been worked out. However, it seems that messages are just purely causing lag, and the more messages, the more lag there is. At first this seems like a fundamental nature of networking, that more messages causes slowdown, but this seems overly clear with even simple mphx usage.

Take, for example, the movement example. When moving left to right, it would seem as though there is half the lag than when moving diagonal. The (poorly constructed and optimized) example sends two packets, one for up, and one for across. Clearly, with both packets being sent, the server can't keep up with the stream of packets and delays clients.

I have a suspicion that this is due to the nature of the program - it is sending more packets than required. In fact, I believe it is sending an update every second! In reality, this program could send one packet per second, and with tweening, would work just as fine. I'd still like to investigate though.

Also, this could potentially be related to the fact that mphx is based on TCP, where every message must be checked and processed, something that is not the case with UDP. UDP has risen a few times in regards to mphx, however that lack of target support for UDP has always pushed it away from me. There are a few haxe libs relating to UDP usage in haxe, however these are generally in the form of C++ externs, thus not really aligning with the 'supports all the targets!' idea mphx has.

mphx lag

5Mixer commented 8 years ago

Duplicated issue. Computer glitched out? :confused: