Question

I have an AIR server application. Several mobile clients connect to it. Everything works good, if there is only one client, but when the server sends data to several clients in a loop, the clients fail to process the data immediately. The data is late by one step.

This bit of code is inside a for loop:

clients[i].client.writeObject(data);
clients[i].client.flush();

Only the client sending the data is getting the update from the server. Everyone else is quiet for one step. If the client sends another message, then all other clients are updated to the state of previously sent update.

The code is fine on clients, as the client running on a computer is receiving the updates on time. Only the mobile clients are failing to update.

What could be the reason for this issue?

What is the proper way of sending data to multiple client sockets at the same time?

Was it helpful?

Solution

I have solved the issue by setting a timer to delay the data transfer by 1/3 of a second. Less delay time caused the same issue. I do not think it is the only solution, but it worked. The problem with this solution is, if the there are 100 clients, the last will receive the data updates in 30 seconds.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top