diff --git a/src/Server/Websockets.php b/src/Server/Websockets.php index 0c34c84..01fe832 100644 --- a/src/Server/Websockets.php +++ b/src/Server/Websockets.php @@ -31,10 +31,14 @@ class Websockets implements MessageComponentInterface echo sprintf('Connection %d sending message "%s"' . "\n" , $from->resourceId, $msg); - foreach ($this->clients as $client) { - if ($from !== $client) { - // The sender is not the receiver, send to each client connected - $client->send("update"); + $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(json_encode(['action'=>"update", 'method'=>$data['method']])); + } } } }