How to check if the message has been delivered, websocket php

Asked

Viewed 248 times

10

  • 1

    Look at roughly, doing a programming there at the "end point", if necessary do another programming from there to a database where will be recorded the event, there are N ways to ensure this

  • I give or don’t give the 50?

1 answer

8


The class has some predictions for failure: the wsSendClientMessage method of this class returns false if not all content could be sent, and the class keeps "dripping" clients periodically to detect a locked or disconnected client.

If you need to be sure immediately that the customer has received and understood the message, have the customer send a confirmation message. Even if it was a Socket.IO framework, which does automatic reconnection and retransmission, a positive confirmation is the best way.

  • 1

    Can you flatten those predictions ? I’m using to be class-like in the future and I wouldn’t want to make serious mistakes. On the solution of the question I ended up going in that same way, thank you!

  • Yes, if you look at the code of the wsSendClientMessage method, you can see that it sends the message in pieces, and only returns true after the last piece has been sent (but nothing guarantees that it is received on the other side, the data is "flying" on the network for a short time). The wsCheckIdleClients() method checks clients who have not sent a message or responded to the ping, and disconnects those who have been out of the air for too long.

  • But this in your view is unproductive ? Why ?

  • No, the class is fulfilling its obligation, which is to detect disconnection, even because its code can pick up this hook to reconnect, but does not solve by itself the problem imposed by the question.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.