For example, currently I have to loop over each object and Stringify the object parameters, sending a separate message for every object in the array. This makes the process really slow, and causes some sync problems between users. How can I stringify and send all my objects at once and parse the result?
Client is javascript and the server uses ratchet for php.
for (let i = circles.length - 1; i >= 0; i--) {
if (connected) {
websocket_server.send(
JSON.stringify({
'type': 'circleData',
'user_id': circles[i].user,
'i': i,
'x': circles[i].x,
'y': circles[i].y,
'r': circles[i].r,
'c': circles[i].c,
})
);
}
}