Beispiel #1
0
 /**
  * {@inheritdoc}
  */
 public function getSubProtocols()
 {
     if ($this->_app instanceof WsServerInterface) {
         return $this->_app->getSubProtocols();
     } else {
         return array();
     }
 }
 /**
  * @param string
  * @return boolean
  */
 public function isSubProtocolSupported($name)
 {
     if (!$this->isSpGenerated) {
         if ($this->component instanceof WsServerInterface) {
             $this->acceptedSubProtocols = array_flip($this->component->getSubProtocols());
         }
         $this->isSpGenerated = true;
     }
     return array_key_exists($name, $this->acceptedSubProtocols);
 }
 /**
  * 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);
 }
Beispiel #4
0
 /**
  * {@inheritdoc}
  */
 function onError(ConnectionInterface $conn, \Exception $e)
 {
     return $this->_component->onError($conn, $e);
 }
Beispiel #5
0
 /**
  * An error has occurred, let the listening application know
  * @param \Exception                        $e
  * @param \React\Socket\ConnectionInterface $conn
  */
 public function handleError(\Exception $e, $conn)
 {
     $this->app->onError($conn->decor, $e);
 }
 /**
  * @return mixed
  */
 public function getSubProtocols()
 {
     return $this->decorated->getSubProtocols();
 }
Beispiel #7
0
 /**
  * {@inheritdoc}
  */
 function onError(ConnectionInterface $conn, \Exception $e)
 {
     if (!$this->isBlocked($conn->remoteAddress)) {
         $this->_decorating->onError($conn, $e);
     }
 }