You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I'm trying to create a chat with symfony 3 and GosWebSocketBundle. This bundle use Autobahn and Ratchet to use WebSocket. My server actually work except when i stop it/restart it, the client reconnect successfully, but on publish, i got Uncaught exception: Autobahn not connected
It only append when the server is on when we loading the page, then restart it and let autobahn reconnect by it own.
<?phpnamespaceCoreBundle\Topic;
useGos\Bundle\WebSocketBundle\Topic\TopicInterface;
useGos\Bundle\WebSocketBundle\Client\ClientManipulatorInterface;
useRatchet\ConnectionInterface;
useRatchet\Wamp\Topic;
useGos\Bundle\WebSocketBundle\Router\WampRequest;
classChatTopicimplementsTopicInterface
{
protected$clientManipulator;
/** * @param ClientManipulatorInterface $clientManipulator */publicfunction__construct(ClientManipulatorInterface$clientManipulator)
{
$this->clientManipulator = $clientManipulator;
}
/** * This will receive any Subscription requests for this topic. * * @param ConnectionInterface $connection * @param Topic $topic * @param WampRequest $request * @return void */publicfunctiononSubscribe(ConnectionInterface$connection, Topic$topic, WampRequest$request)
{
$user = $this->clientManipulator->getClient($connection);
//this will broadcast the message to ALL subscribers of this topic.$topic->broadcast(['msg' => $user . " has joined " . $topic->getId()]);
}
/** * This will receive any UnSubscription requests for this topic. * * @param ConnectionInterface $connection * @param Topic $topic * @param WampRequest $request * @return void */publicfunctiononUnSubscribe(ConnectionInterface$connection, Topic$topic, WampRequest$request)
{
//this will broadcast the message to ALL subscribers of this topic.$topic->broadcast(['type' => 'call', 'msg' => $connection->resourceId . " has left " . $topic->getId()]);
}
/** * This will receive any Publish requests for this topic. * * @param ConnectionInterface $connection * @param Topic $topic * @param WampRequest $request * @param $event * @param array $exclude * @param array $eligible * @return mixed|void */publicfunctiononPublish(ConnectionInterface$connection, Topic$topic, WampRequest$request, $event, array$exclude, array$eligible)
{
/* $topic->getId() will contain the FULL requested uri, so you can proceed based on that if ($topic->getId() === 'acme/channel/shout') //shout something to all subs. */$topic->broadcast([
'type' => 'msg',
'msg' => $event,
]);
}
/** * Like RPC is will use to prefix the channel * @return string */publicfunctiongetName()
{
return'chat.topic';
}
}
I'm trying to create a chat with symfony 3 and GosWebSocketBundle. This bundle use Autobahn and Ratchet to use WebSocket. My server actually work except when i stop it/restart it, the client reconnect successfully, but on publish, i got Uncaught exception: Autobahn not connected
It only append when the server is on when we loading the page, then restart it and let autobahn reconnect by it own.
GosWebSocket Configuration:
ChatTopic services and routes:
ChatTopic.php
chatbox.html.twig
The text was updated successfully, but these errors were encountered: