Just started my first Socket.IO project and everything is working fine so far. However, I have a question about my current setup:
I have a server job which takes some time to run, so I'm using Socket.IO to push updates about the process to the client. When the process is finished, I close the connection. But as soon as the client refreshes the result page or closes and reopens the URL in the browser, he receives again every message which has been sent so far.
This leads to the following behavior:
First run:
debug: websocket writing 5:::{"name":"debug","args":["Loading data ..."]}
debug: websocket writing 5:::{"name":"debug","args":["Data received: 10859 bytes"]}
debug: websocket writing 5:::{"name":"debug","args":["Processing result ..."]}
Second run (Browser window reload):
debug: websocket writing 5:::{"name":"debug","args":["Loading data ..."]}
debug: websocket writing 5:::{"name":"debug","args":["Loading data ..."]}
debug: websocket writing 5:::{"name":"debug","args":["Data received: 10859 bytes"]}
debug: websocket writing 5:::{"name":"debug","args":["Processing result ..."]}
debug: websocket writing 5:::{"name":"debug","args":["Data received: 10859 bytes"]}
debug: websocket writing 5:::{"name":"debug","args":["Processing result ..."]}
Is there any way to drop the old messages, which have already been received by the client and only send the new ones (since the connection has been started again)? I already tried socket.volatile.emit instead of socket.emit without luck.