I want to use a Ratchet (http://socketo.me) for permanent connection between iPhone Apps and Server. And I need to exchange data between apps and server.
From this example (http://socketo.me/docs/hello-world) I've found out that I have a function onMessage that will be called when the App send a massage to the server and the server could send a response to the App.
But the server also must have an ability to send data to the app without getting data from app. For example, the connection between app and server has been established. Something happened on the server and we need to send a new data to the app. How can I do it and is it possible?
The main question is how can I send data to the App from the server?
Thank you for any help.
send() The WebSocket. send() method enqueues the specified data to be transmitted to the server over the WebSocket connection, increasing the value of bufferedAmount by the number of bytes needed to contain the data.
websockets frame buffer: its size depends both on the size and the number of frames it contains. By default the maximum size is 1MB and the maximum number is 32.
Web sockets provide a reliable and easy-to-implement way to connect web clients with business applications which use messaging queues for inter-module communication.
There is no guarantee of the successful delivery of a web socket message to the peer, but if the action of sending a message causes an error known to the container, the API throws it.
That is indeed possible. You need to communicate with the WebSocket server process somehow. You can do that by using some form of message passing, be it RPC or a message queue.
Ratchet itself is based on the React event loop. This means that any form of communication with Ratchet must be integrated with that event loop. On the React homepage you can see some of the integrations that already exist:
In the Ratchet documentation there is a tutorial on how to use React/ZMQ in order to push messages from anywhere to your WebSocket server.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With