예제 #1
0
 /**
  * Data has been received from React
  * @param string                            $data
  * @param \React\Socket\ConnectionInterface $conn
  */
 public function handleData($data, $conn)
 {
     try {
         $this->app->onMessage($conn->decor, $data);
     } catch (\Exception $e) {
         $this->handleError($e, $conn);
     }
 }
예제 #2
0
 /**
  * Triggered when a client sends data through the socket
  * @param  \Ratchet\ConnectionInterface $from The socket/connection that sent the message to your application
  * @param  string $msg The message received
  * @throws \Exception
  *
  * expects:
  * { 'cmd': "identifier", 'payload': {<data>}}
  * could use bson instead
  */
 function onMessage(ConnectionInterface $from, $msg)
 {
     $from = $this->connections->offsetGet($from);
     if (null === ($json = @json_decode($msg, true))) {
         throw new JsonException();
     }
     if (!is_array($json)) {
         throw new Exception("Invalid message");
     }
     $this->wrapped->onMessage($from, $json);
 }
예제 #3
0
 /**
  * {@inheritdoc}
  */
 function onMessage(ConnectionInterface $from, $msg)
 {
     return $this->_component->onMessage($from, $msg);
 }
예제 #4
0
 /**
  * {@inheritdoc}
  */
 public function onMessage(ConnectionInterface $from, $msg)
 {
     return $this->_app->onMessage($from, $msg);
 }
 /**
  * @param ConnectionInterface $connection
  * @param string              $msg
  *
  * @return mixed
  */
 public function onMessage(ConnectionInterface $connection, $msg)
 {
     return $this->decorated->onMessage($connection, $msg);
 }
예제 #6
0
 /**
  * {@inheritdoc}
  */
 function onMessage(ConnectionInterface $from, $msg, $server)
 {
     return $this->_decorating->onMessage($from, $msg, $server);
 }