1 | <?php |
||
9 | class ServerHandler extends WebSocket |
||
10 | { |
||
11 | |||
12 | /* |
||
13 | * if You need to parse URI context like /messanger/chat/JKN324jn4213 |
||
14 | * You can do so by placing URI parts into an array - $pathParams, when Socket will receive a connection |
||
15 | * this variable will be appropriately set to key => value pairs, ex.: ':context' => 'chat' |
||
16 | * Otherwise leave $pathParams as an empty array |
||
17 | */ |
||
18 | |||
19 | public $pathParams = [':entity', ':context', ':token']; |
||
20 | private $clients = []; |
||
21 | |||
22 | public function onOpen(ConnectionContract $conn) |
||
27 | |||
28 | public function onMessage(ConnectionContract $recv, $msg) |
||
33 | |||
34 | public function onClose(ConnectionContract $conn) |
||
39 | |||
40 | /** |
||
41 | * @param ConnectionContract $conn |
||
42 | * @param WebSocketException $ex |
||
43 | */ |
||
44 | public function onError(ConnectionContract $conn, WebSocketException $ex) |
||
48 | |||
49 | /** |
||
50 | * You may want to implement these methods to bring ping/pong events |
||
51 | * @param ConnectionContract $conn |
||
52 | * @param string $msg |
||
53 | */ |
||
54 | public function onPing(ConnectionContract $conn, $msg) |
||
58 | |||
59 | /** |
||
60 | * @param ConnectionContract $conn |
||
61 | * @param $msg |
||
62 | * @return mixed |
||
63 | */ |
||
64 | public function onPong(ConnectionContract $conn, $msg) |
||
68 | } |
||
69 |