logger = $logger; $this->manager = $manager; } /** * {@inheritdoc} */ public function onPublish(Conn $conn, $topic, $event, array $exclude, array $eligible) { $this->logger->error(sprintf('Publishing on topic %s', $topic->getId()), ['event' => $event, 'topic' => $topic]); $topic->broadcast($event); } /** * {@inheritdoc} */ public function onCall(Conn $conn, $id, $topic, array $params) { $this->logger->error(sprintf('Received RPC call on topic %s', $topic->getId()), ['topic' => $topic]); $conn->callError($id, $topic, 'RPC not supported on this demo'); } /** * {@inheritdoc} */ public function onSubscribe(Conn $conn, $topic) { if ($this->manager->subscribe($conn, $topic)) { $this->logger->debug(sprintf('Subscription received on topic %s', $topic->getId()), ['topic' => $topic]); } else { $this->logger->error(sprintf('Subscription received on topic %s, user is not allowed', $topic->getId()), ['topic' => $topic]); } } /** * {@inheritdoc} */ public function onUnSubscribe(Conn $conn, $topic) { $this->logger->debug(sprintf('Unsubscription received on topic %s', $topic->getId()), ['topic' => $topic]); $this->manager->unsubscribe($conn, $topic); } /** * {@inheritdoc} */ public function onOpen(Conn $conn) { $this->logger->debug('[WS] Connection request accepted'); $this->manager->openConnection($conn); } /** * {@inheritdoc} */ public function onClose(Conn $conn) { $this->logger->debug('[WS] Connection closed'); $this->manager->closeConnection($conn); } /** * {@inheritdoc} */ public function onError(Conn $conn, \Exception $e) { $this->logger->error('[WS] Connection error', ['exception' => $e]); } }