/** * 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); } }
/** * 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); }
/** * {@inheritdoc} */ function onMessage(ConnectionInterface $from, $msg) { return $this->_component->onMessage($from, $msg); }
/** * {@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); }
/** * {@inheritdoc} */ function onMessage(ConnectionInterface $from, $msg, $server) { return $this->_decorating->onMessage($from, $msg, $server); }