websockets in faces3.php
This commit is contained in:
parent
7e53e1666a
commit
be6bec92c0
1 changed files with 8 additions and 4 deletions
|
@ -31,10 +31,14 @@ class Websockets implements MessageComponentInterface
|
||||||
echo sprintf('Connection %d sending message "%s"' . "\n"
|
echo sprintf('Connection %d sending message "%s"' . "\n"
|
||||||
, $from->resourceId, $msg);
|
, $from->resourceId, $msg);
|
||||||
|
|
||||||
|
$data = @json_decode($msg);
|
||||||
|
if(!empty($data) && $data['action'] == 'update' && isset($data['method']))
|
||||||
|
{
|
||||||
foreach ($this->clients as $client) {
|
foreach ($this->clients as $client) {
|
||||||
if ($from !== $client) {
|
if ($from !== $client) {
|
||||||
// The sender is not the receiver, send to each client connected
|
// The sender is not the receiver, send to each client connected
|
||||||
$client->send("update");
|
$client->send(json_encode(['action'=>"update", 'method'=>$data['method']]));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue