'how to send message to specific one user id using ratchet Laravel?

chat.php how to send message to specific user id?

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) {
        if ($from !== $client) {
            // The sender is not the receiver, send to each client connected
            $client->send($msg);
        }
    }
}

How to send a message to a specific user id?

reference link http://socketo.me/docs/hello-world



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source