I hope someone can help me I have looked and I know very little about websockets. P.S: We are working in a legacy code so it is pure php ( no laravel, symfony, nothing ) We have a partner that our server will have to listen to their websocket (ws://webfeeder.cedrotech.com/ws).
The only example they gave was a client to server ( javascript ) but on our end we will need to keep listening to their websocket and manipulate the data, save it and than write a restapi so that our mobileapp can be updated ( it needs to be updating in real time ).
So I havent' found any example where I can implement a websocket where I will connect and login to their websocket and keep listening so I can make the updates when necessary to the database according to their response. This is their Javascript example but I don't have any idea how to put that in a php form with the needs that we have.
var wsUri = "ws://201.77.219.223/ws";
websocket = new WebSocket(wsUri);
websocket.onopen = function(evt) { console.log("Connected to Endpoint!"); }; websocket.onmessage = function(evt) { console.log("Message Received: " + evt.data); }; websocket.onerror = function(evt) { console.log("ERROR: " + evt.data); }; function doSend(message) { console.log("Message Sent: " + message); websocket.send(message); } doSend('{ "module": "login", "service": "authentication", "parameters": {"login": "test", "password": "123456"}}');
If anyone can help, I would really appreciate it! Thanks!
What I have tried:
I have tried many codes with socket but I am not finding a away to do like my question asks.