public function onMessage(ConnectionInterface $from, $msg) {
$numRecv = count($this->clients) - 1;
echo sprintf('Connection %d sending message "%s" to %d other connection%s' . "\n"
, $from->resourceId, $msg, $numRecv, $numRecv == 1 ? '' : 's');
foreach ($this->clients as $client) {
$client->send($this->response->make($msg));
$ms= json_decode($msg);
$ms= (object)$ms;
\App\Messages::create(['body'=>$session_name,'user_id'=>$ms->client->data->user_id,'chat_id'=>1]);
}
}
у меня так работает