Well, that not much of a problem, but we are talking about the logic here :P
Today I updated the demo a little to fix the connection issue (5x Client connected, Client disconnected) and a few fixes to switch from Agent to Gateway properly.
I won't work out the sync method because I don't have the time for it. It's not a really big problem. You have to parse & keep track of the environment properly to transmit a clean set of the current things going around near you.
I will share the source code with you if anyone wants to use them, feel free to copy/edit the way you need it.
Credits to Vitalka for his awesome loader, once again :P