oc-websockets
oc-websockets copied to clipboard
Php send
How to send message by php?
Sorry, not supported yet.
what else do we use web sockets for if not pushing data to the client ?
Hi @daslicht, the implemented MessageComponentInterface
is used as a Event/Message Bus between Web Socket clients. For now, you can implement a PHP client to send custom messages to JavaScript/Front-end clients.
Using, for example: https://github.com/Textalk/websocket-php You can write:
$client = new WebSocket\Client('ws://url.to.the.same.as.on.javascript');
$client->send(json_encode(['event' => 'foo', 'payload' => ['bar' => 'baz']]));
And JavaScript WebSocket clients will receive this message.
But I know, it would be nice to have a way to send it right from October's infrastructure.
Ahh ok great ! I will try it soon :)
hi #leocavalcante
Do you have an example using textalk as a client using your websocket plugin ?