websockets in faces3.php

This commit is contained in:
Ruben 2016-11-01 22:42:45 +01:00
parent 7e53e1666a
commit be6bec92c0

View file

@ -31,10 +31,14 @@ class Websockets implements MessageComponentInterface
echo sprintf('Connection %d sending message "%s"' . "\n"
, $from->resourceId, $msg);
$data = @json_decode($msg);
if(!empty($data) && $data['action'] == 'update' && isset($data['method']))
{
foreach ($this->clients as $client) {
if ($from !== $client) {
// The sender is not the receiver, send to each client connected
$client->send("update");
$client->send(json_encode(['action'=>"update", 'method'=>$data['method']]));
}
}
}
}