examples/chat.php
public function onMessage(WebSocketTransportInterface $user, WebSocketMessageInterface $msg) {
        $this->logger->notice("Broadcasting " . strlen($msg->getData()) . " bytes");

        foreach($this->getConnections() as $client){
            $client->sendString("User {$user->getId()} said: ".$msg->getData());
        }
    }
public function onMessage(WebSocketTransportInterface $user, WebSocketMessageInterface $msg) {
        $this->logger->notice("Broadcasting " . strlen($msg->getData()) . " bytes");

        foreach($this->getConnections() as $client){
            $client->sendString("User {$user->getId()} said: ".$msg->getData());
        }
    }
public function onMessage ( WebSocketTransportInterface $ user , WebSocketMessageInterface $ msg ) { $ this -> logger -> notice ( "Broadcasting " . strlen ( $ msg -> getData ( ) ) . " bytes" ) ; foreach ( $ this -> getConnections ( ) as $ client ) { $ client -> sendString ( "User {$user->getId()} said: " . $ msg -> getData ( ) ) ; } }
Broadcast messages sent by a user to everyone in the room

@param WebSocketTransportInterface $user
@param WebSocketMessageInterface $msg
Broadcast messages sent by a user to everyone in the room