1 | <?php |
||
36 | class Chat implements MessageComponentInterface |
||
37 | { |
||
38 | /* |
||
39 | |-------------------------------------------------------------------------- |
||
40 | | Chat Class |
||
41 | |-------------------------------------------------------------------------- |
||
42 | | |
||
43 | | This Class handles the all the main functionalities for this ChatApp. |
||
44 | | |
||
45 | */ |
||
46 | |||
47 | protected $clients; |
||
48 | |||
49 | /** |
||
50 | * Create a new class instance. |
||
51 | * |
||
52 | * @return void |
||
|
|||
53 | */ |
||
54 | public function __construct() |
||
58 | |||
59 | /** |
||
60 | * Open the Socket Connection and get client connection |
||
61 | * |
||
62 | * @param ConnectionInterface $conn To store client details |
||
63 | * |
||
64 | * @return void |
||
65 | */ |
||
66 | public function onOpen(ConnectionInterface $conn) |
||
73 | |||
74 | /** |
||
75 | * Set Session Id in Connection object |
||
76 | * |
||
77 | * @param ConnectionInterface $conn To store client details |
||
78 | * |
||
79 | * @return $conn |
||
80 | */ |
||
81 | public function setID($conn) |
||
89 | |||
90 | /** |
||
91 | * Send Messages to Clients |
||
92 | * |
||
93 | * @param ConnectionInterface $from To store client details |
||
94 | * @param string $msg To store message |
||
95 | * |
||
96 | * @return void |
||
97 | */ |
||
98 | public function onMessage(ConnectionInterface $from, $msg) |
||
196 | |||
197 | /** |
||
198 | * To Call SideBar Class |
||
199 | * |
||
200 | * @param string $data To store data |
||
201 | * |
||
202 | * @return string |
||
203 | */ |
||
204 | public function onSidebar($data) |
||
209 | |||
210 | /** |
||
211 | * To Call Conversation Class |
||
212 | * |
||
213 | * @param string $data to store data |
||
214 | * @param boolean $para to store True/False |
||
215 | * |
||
216 | * @return string |
||
217 | */ |
||
218 | public function onConversation($data, $para) |
||
223 | |||
224 | /** |
||
225 | * To Call Receiver Class |
||
226 | * |
||
227 | * @param string $data to store data |
||
228 | * @param boolean $para to store True/False |
||
229 | * |
||
230 | * @return string |
||
231 | */ |
||
232 | public function onReceiver($data, $para) |
||
237 | |||
238 | /** |
||
239 | * To Call Search Class |
||
240 | * |
||
241 | * @param string $data to store data |
||
242 | * |
||
243 | * @return string |
||
244 | */ |
||
245 | public function onSearch($data) |
||
250 | |||
251 | /** |
||
252 | * To Call Compose Class |
||
253 | * |
||
254 | * @param string $data to store data |
||
255 | * |
||
256 | * @return string |
||
257 | */ |
||
258 | public function onCompose($data) |
||
263 | |||
264 | /** |
||
265 | * To Call Reply Class |
||
266 | * |
||
267 | * @param string $data to store data |
||
268 | * |
||
269 | * @return string |
||
270 | */ |
||
271 | public function onReply($data) |
||
276 | |||
277 | /** |
||
278 | * To Call Online Class |
||
279 | * |
||
280 | * @param ConnectionInterface $conn To store client details |
||
281 | * |
||
282 | * @return void |
||
283 | */ |
||
284 | public function onClose(ConnectionInterface $conn) |
||
290 | |||
291 | /** |
||
292 | * To Show error due to any problem occured |
||
293 | * |
||
294 | * @param ConnectionInterface $conn To store client details |
||
295 | * @param \Exception $e To store exception |
||
296 | * |
||
297 | * @return void |
||
298 | */ |
||
299 | public function onError(ConnectionInterface $conn, \Exception $e) |
||
304 | |||
305 | } |
||
306 |
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.