1 | <?php |
||
20 | class WebSocketHandler implements MessageComponentInterface |
||
21 | { |
||
22 | /** |
||
23 | * The channel manager. |
||
24 | * |
||
25 | * @var \BeyondCode\LaravelWebSockets\WebSockets\Channels\ChannelManager |
||
26 | */ |
||
27 | protected $channelManager; |
||
28 | |||
29 | /** |
||
30 | * Initialize a new handler. |
||
31 | * |
||
32 | * @param \BeyondCode\LaravelWebSockets\WebSockets\Channels\ChannelManager $channelManager |
||
33 | * @return void |
||
|
|||
34 | */ |
||
35 | public function __construct(ChannelManager $channelManager) |
||
39 | |||
40 | /** |
||
41 | * Handle the socket opening. |
||
42 | * |
||
43 | * @param \Ratchet\ConnectionInterface $connection |
||
44 | * @return void |
||
45 | */ |
||
46 | public function onOpen(ConnectionInterface $connection) |
||
54 | |||
55 | /** |
||
56 | * Handle the incoming message. |
||
57 | * |
||
58 | * @param \Ratchet\ConnectionInterface $connection |
||
59 | * @param \Ratchet\RFC6455\Messaging\MessageInterface $message |
||
60 | * @return void |
||
61 | */ |
||
62 | public function onMessage(ConnectionInterface $connection, MessageInterface $message) |
||
70 | |||
71 | /** |
||
72 | * Handle the websocket close. |
||
73 | * |
||
74 | * @param \Ratchet\ConnectionInterface $connection |
||
75 | * @return void |
||
76 | */ |
||
77 | public function onClose(ConnectionInterface $connection) |
||
87 | |||
88 | /** |
||
89 | * Handle the websocket errors. |
||
90 | * |
||
91 | * @param \Ratchet\ConnectionInterface $connection |
||
92 | * @param WebSocketException $exception |
||
93 | * @return void |
||
94 | */ |
||
95 | public function onError(ConnectionInterface $connection, Exception $exception) |
||
103 | |||
104 | /** |
||
105 | * Verify the app key validity. |
||
106 | * |
||
107 | * @param \Ratchet\ConnectionInterface $connection |
||
108 | * @return $this |
||
109 | */ |
||
110 | protected function verifyAppKey(ConnectionInterface $connection) |
||
122 | |||
123 | /** |
||
124 | * Verify the origin. |
||
125 | * |
||
126 | * @param \Ratchet\ConnectionInterface $connection |
||
127 | * @return $this |
||
128 | */ |
||
129 | protected function verifyOrigin(ConnectionInterface $connection) |
||
145 | |||
146 | /** |
||
147 | * Limit the connections count by the app. |
||
148 | * |
||
149 | * @param \Ratchet\ConnectionInterface $connection |
||
150 | * @return $this |
||
151 | */ |
||
152 | protected function limitConcurrentConnections(ConnectionInterface $connection) |
||
164 | |||
165 | /** |
||
166 | * Create a socket id. |
||
167 | * |
||
168 | * @param \Ratchet\ConnectionInterface $connection |
||
169 | * @return $this |
||
170 | */ |
||
171 | protected function generateSocketId(ConnectionInterface $connection) |
||
179 | |||
180 | /** |
||
181 | * Establish connection with the client. |
||
182 | * |
||
183 | * @param \Ratchet\ConnectionInterface $connection |
||
184 | * @return $this |
||
185 | */ |
||
186 | protected function establishConnection(ConnectionInterface $connection) |
||
208 | } |
||
209 |
Adding a
@return
annotation to a constructor is not recommended, since a constructor does not have a meaningful return value.Please refer to the PHP core documentation on constructors.