oc-websockets icon indicating copy to clipboard operation
oc-websockets copied to clipboard

Php send

Open devillom opened this issue 8 years ago • 5 comments

How to send message by php?

devillom avatar Aug 04 '16 05:08 devillom

Sorry, not supported yet.

leocavalcante avatar Aug 04 '16 18:08 leocavalcante

what else do we use web sockets for if not pushing data to the client ?

daslicht avatar Sep 24 '16 11:09 daslicht

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.

leocavalcante avatar Sep 24 '16 13:09 leocavalcante

Ahh ok great ! I will try it soon :)

daslicht avatar Sep 24 '16 13:09 daslicht

hi #leocavalcante

Do you have an example using textalk as a client using your websocket plugin ?

elektrikmoonkey avatar Sep 24 '20 21:09 elektrikmoonkey