payload->event, ':')); if (method_exists($this, $eventName) && $eventName !== 'respond') { call_user_func([$this, $eventName], $this->connection, $this->payload->data ?? new stdClass()); } } /** * Ping the connection. * * @see https://pusher.com/docs/pusher_protocol#ping-pong * @param \Ratchet\ConnectionInterface $connection * @return void */ protected function ping(ConnectionInterface $connection) { $connection->send(json_encode([ 'event' => 'pusher:pong', ])); } /** * Subscribe to channel. * * @see https://pusher.com/docs/pusher_protocol#pusher-subscribe * @param \Ratchet\ConnectionInterface $connection * @param \stdClass $payload * @return void */ protected function subscribe(ConnectionInterface $connection, stdClass $payload) { $this->channelManager->subscribeToChannel($connection, $payload->channel, $payload); } /** * Unsubscribe from the channel. * * @param \Ratchet\ConnectionInterface $connection * @param \stdClass $payload * @return void */ public function unsubscribe(ConnectionInterface $connection, stdClass $payload) { $this->channelManager->unsubscribeFromChannel($connection, $payload->channel, $payload); } }