Ok so I’m facing loads of challenges at the moment. I’m building a java TCP server and flash game client together. It’s going well. But I have a strange problem.
All works fine on my MacBookPro I can run many instances of my game, move about and its smooth. When I try it on my iMac every so often my server receives a malformed message (took me a while to even get this far, as the server used to bug out). O.K. so obviously there is an error in my flash code.
I have a timer - it ticks every 10ms. If two commands need to be sent within 10ms they are grouped together and sent in one packet. If i change this to 1000ms everything works fine (all be it very laggy).
I have a keyboard listener listening for key downs and one for key ups. This finds the key, works out the command to send and adds it to the send queue.
When running this on my iMac (@ 10ms) sometimes instead of adding the messages together with a NEXT token it will concat them with a NULL token (used only for the end of message).
I have narrowed it down to this timer. I think it is somehow firing too fast for flash. So flash is concating the messages together and sending them in one packet (even though I call the socket.flush() method!).
I could increase the timer to 100ms but this is going to have an effect on performance. Is there are solution that will work across the board?
Thank you for reading all this ^^ and your help,
Dan