Why better performance with roInput than roDatagramSocket?
So I am working on a game that uses Android devices as the controls. The point of the game is to allow a large number of players to interact on one screen. I initially started out using roInput and RESTful HTTP to give the Roku instructions. Then I realized Roku can handle low level networking, it can receive raw UDP packets using roDatagramSocket. I am new to networking, but I thought I'd give it a shot because I knew it would be 10X faster than using RESTful HTTP communication. Not so!
It seems to be something to with roDatagramSocket creating a queue of its received messages, and if the Roku hangs, well then there is lots of latency. Also for my roInputEvent I am using port.GetMessage() where as in my roSocketEvent I am using wait(1, port) , because for whatever reason I never receive any data with port.GetMessage() on my roSocketEvent. roInput seems to drop the messages, if it hangs the sprites will just skip a few pixels, not hang and then process all the data moments later. It also takes a huge performance hit if there are multiple players connected, could it be that the Roku is receiving and then processing ALL the data from the players and thus becoming sluggish? How would I go about only processing whatever data is currently available on each loop through my while statement, instead of ALL data that has been captured since the last while loop?
These are just my best guesses so far as to what is going on.
I would really appreciate any help, I just spent my entire night switching to UDP for the performance, and it seems like a complete waste.
Re: Why better performance with roInput than roDatagramSocke
I think I just realized what's wrong and I feel like an idiot. Is amazing what a night of sleep can do for your thinking process.
I am currently only processing 1 packet of data each pass through my entire while statement. So if I'm running at 60fps I'm only processing 60 packets per second. But as more connections are active I may be receiving 100+ packets per second. And thus the state of my game is far behind.
Think I just need to process all available packets each pass through...
Not at home to try this, but logically it makes sense.