fortune icon indicating copy to clipboard operation
fortune copied to clipboard

Syncing client with server

Open echo66 opened this issue 9 years ago • 5 comments

Greetings!

Are there any working examples showing how to sync data between server and clients?

Thanks in advance!

echo66 avatar Feb 16 '16 11:02 echo66

Not yet, I will come up with some examples showcasing a few use cases soon enough. For now there's the tests: https://github.com/fortunejs/fortune/blob/master/test/integration/net/ws_client.js

gr0uch avatar Feb 16 '16 16:02 gr0uch

I'm reading both client and server code. Where do I state the time interval between syncs?

echo66 avatar Feb 16 '16 18:02 echo66

There's no time interval, it's not polling. It uses WebSocket, so the server actually sends updates to the client at any time during the connection.

gr0uch avatar Feb 16 '16 19:02 gr0uch

Oh, ok! :+1:

So, that raises the question: every CRUD action by a client will be send to all other clients?

echo66 avatar Feb 19 '16 18:02 echo66

By default, yes. However, the server can modify or omit the change before sending anything to clients via the change function.

If you have a cluster of servers, it gets a little tricky because then each server has to coordinate changes among each other to reach the right clients. It is possible to do but isn't abstracted by Fortune.js, at least not yet (I think it should take advantage of multiple cores by default).

gr0uch avatar Feb 19 '16 18:02 gr0uch