1 | <?php |
||
38 | class WebSocketManager extends AbstractManager implements |
||
39 | MessageComponentInterface, |
||
1 ignored issue
–
show
|
|||
40 | EventSubscriberInterface, |
||
1 ignored issue
–
show
|
|||
41 | HandlerInterface |
||
1 ignored issue
–
show
|
|||
42 | { |
||
43 | |||
44 | use DelegatesMessagesTrait; |
||
45 | |||
46 | /** |
||
47 | * @var IoServer the Websocket server |
||
48 | */ |
||
49 | private $_websocket; |
||
50 | |||
51 | /** |
||
52 | * @var \SplObjectStorage the connected clients |
||
53 | */ |
||
54 | private $_connectedClients; |
||
55 | |||
56 | /** |
||
57 | * @var \SplObjectStorage the authenticated clients |
||
58 | */ |
||
59 | private $_authenticatedClients; |
||
60 | |||
61 | |||
62 | /** |
||
63 | * WebSocketManager constructor. |
||
64 | * |
||
65 | * @param Configuration $configuration |
||
66 | * @param LoggerInterface $logger |
||
67 | * @param EventDispatcher $eventDispatcher |
||
68 | * @param LoopInterface $loop |
||
69 | */ |
||
70 | public function __construct( |
||
89 | |||
90 | |||
91 | /** |
||
92 | * @inheritdoc |
||
93 | */ |
||
94 | public static function getSubscribedEvents() |
||
101 | |||
102 | |||
103 | /** |
||
104 | * Called right before the main loop is started |
||
105 | */ |
||
106 | public function onMainLoopStarted() |
||
113 | |||
114 | |||
115 | /** |
||
116 | * @param InstanceStatusUpdatesEvent $event |
||
117 | */ |
||
118 | public function onInstanceStatusUpdates(InstanceStatusUpdatesEvent $event) |
||
129 | |||
130 | |||
131 | /** |
||
132 | * @inheritdoc |
||
133 | */ |
||
134 | public function onOpen(ConnectionInterface $conn) |
||
139 | |||
140 | |||
141 | /** |
||
142 | * @inheritdoc |
||
143 | */ |
||
144 | public function onClose(ConnectionInterface $conn) |
||
151 | |||
152 | |||
153 | /** |
||
154 | * @inheritdoc |
||
155 | */ |
||
156 | public function onError(ConnectionInterface $conn, \Exception $e) |
||
160 | |||
161 | |||
162 | /** |
||
163 | * @inheritdoc |
||
164 | */ |
||
165 | public function handleMessage(AbstractMessage $message, ConnectionInterface $sender) |
||
186 | |||
187 | |||
188 | /** |
||
189 | * Dispatches incoming client messages to the appropriate handlers |
||
190 | * |
||
191 | * @param ConnectionInterface $from |
||
192 | * @param string $msg |
||
193 | */ |
||
194 | public function onMessage(ConnectionInterface $from, $msg) |
||
235 | |||
236 | |||
237 | /** |
||
238 | * @param AbstractMessage $message |
||
239 | * @param ConnectionInterface $target |
||
240 | */ |
||
241 | private function sendMessage(AbstractMessage $message, ConnectionInterface $target) |
||
245 | |||
246 | } |
||
247 |