Is there any way to know socket io emit failed and success, something like ajax callback methods: onSuccess, onError? For socket io emit i only find:
socket.emit('publish', {message:'test message'},function (data) { alert("")})
This callback only be called when the server send an ack response.But it can not apply for this situation:
At the moment of emit message to server, there is bad network or lost connection, that means server not receive this message, so the client callback function is not called.
What I want is:
When I call the socket io emit, if it fails, I want to retry 3 times.
setTimeout
and a few flags. – Tman