Private
Public Access
1
0

created working session and client handler w/ websocket

This commit is contained in:
2016-10-19 13:27:55 +02:00
parent fbfbe5a13b
commit 28f42db14a
10 changed files with 300 additions and 62 deletions

View File

@@ -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()]);
}