created working session and client handler w/ websocket
This commit is contained in:
@@ -2,7 +2,7 @@
|
||||
|
||||
namespace Mine\SeekerBundle\Topic;
|
||||
|
||||
//use Gos\Bundle\WebSocketBundle\Client\ClientManipulatorInterface;
|
||||
use Gos\Bundle\WebSocketBundle\Client\ClientManipulatorInterface;
|
||||
use Gos\Bundle\WebSocketBundle\Topic\TopicInterface;
|
||||
use Gos\Bundle\WebSocketBundle\Router\WampRequest;
|
||||
use Ratchet\ConnectionInterface;
|
||||
@@ -10,15 +10,18 @@ use Ratchet\Wamp\Topic;
|
||||
|
||||
class AcmeTopic implements TopicInterface
|
||||
{
|
||||
// protected $clientManipulator;
|
||||
//
|
||||
// /**
|
||||
// * @param ClientManipulatorInterface $clientManipulator
|
||||
// */
|
||||
// public function __construct(ClientManipulatorInterface $clientManipulator)
|
||||
// {
|
||||
// $this->clientManipulator = $clientManipulator;
|
||||
// }
|
||||
/** @var ClientManipulatorInterface */
|
||||
protected $clientManipulator;
|
||||
|
||||
/**
|
||||
* AcmeTopic constructor.
|
||||
*
|
||||
* @param $clientManipulator ClientManipulatorInterface
|
||||
*/
|
||||
public function __construct(ClientManipulatorInterface $clientManipulator)
|
||||
{
|
||||
$this->clientManipulator = $clientManipulator;
|
||||
}
|
||||
|
||||
/**
|
||||
* This will receive any Subscription requests for this topic.
|
||||
@@ -30,12 +33,12 @@ class AcmeTopic implements TopicInterface
|
||||
*/
|
||||
public function onSubscribe(ConnectionInterface $connection, Topic $topic, WampRequest $request)
|
||||
{
|
||||
// $user = $this->clientManipulator->getClient($connection);
|
||||
$user = "";
|
||||
//this will broadcast the message to ALL subscribers of this topic.
|
||||
/** this will broadcast the message to ALL subscribers of this topic. */
|
||||
$user = $this->clientManipulator->getClient($connection);
|
||||
dump($user);
|
||||
$topic->broadcast([
|
||||
'msg' => $connection->resourceId . " has joined " . $topic->getId(),
|
||||
'user' => $user
|
||||
'user' => $this->getName()
|
||||
]);
|
||||
}
|
||||
|
||||
@@ -49,7 +52,9 @@ class AcmeTopic implements TopicInterface
|
||||
*/
|
||||
public function onUnSubscribe(ConnectionInterface $connection, Topic $topic, WampRequest $request)
|
||||
{
|
||||
//this will broadcast the message to ALL subscribers of this topic.
|
||||
/** this will broadcast the message to ALL subscribers of this topic. */
|
||||
$user = $this->clientManipulator->getClient($connection);
|
||||
dump($user);
|
||||
$topic->broadcast(['msg' => $connection->resourceId . " has left " . $topic->getId()]);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user