fw42 / honeymap

Real-time websocket stream of GPS events on a fancy SVG world map
http://map.honeynet.org/
GNU Lesser General Public License v3.0
219 stars 88 forks source link

Send markers to all clients connected #3

Closed adulau closed 11 years ago

adulau commented 11 years ago

If socket.emit is used, the marker is only sent to a single client. If you more than one client connected, it will send different markers sent to each client. Usually you want to broadcast the markers to all clients including the initial requesting client. As the global map should be consistent among clients.

broadcast.emit broadcasts to everyone except the triggering client. emit is kept for the triggering client.

rep commented 11 years ago

Hey Alexandre, cool to have raised your interest in this :)

Anyway we only used the random stuff for testing pretty much. I'm not sure about the commit though, looks like this random function will be created for every connection and a new timer set through setInterval. Certainly not optimal in terms of memory usage - and some broadcast way would be better. On the other hand if I got this right your patch will amplify traffic a lot if for every connection it broadcasts a new random location every second.

Also the JS looks a bit broken/weird?

adulau commented 11 years ago

Hi Mark,

Thanks for the feedback. The commit was there to raise a general question and not foreseen to be pulled back into the code. Usually for such kind of map, you prefer to have a consistent view between clients at the same time. I was wondering if this is not issue at the current stage and how this can be solved. You are right for the broadcast this is currently suboptimal and I suppose the proper to do it would be to create a dedicated namespace for broadcasting the markers to all connected clients. I'll do some test.

Thanks a lot.