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) |
||
188 | |||
189 | /** |
||
190 | * To Call SideBar Class |
||
191 | * |
||
192 | * @param string $data To store data |
||
193 | * |
||
194 | * @return string |
||
195 | */ |
||
196 | public function onSidebar($data) |
||
201 | |||
202 | /** |
||
203 | * To Call Conversation Class |
||
204 | * |
||
205 | * @param string $data to store data |
||
206 | * @param boolean $para to store True/False |
||
207 | * |
||
208 | * @return string |
||
209 | */ |
||
210 | public function onConversation($data, $para) |
||
215 | |||
216 | /** |
||
217 | * To Call Receiver Class |
||
218 | * |
||
219 | * @param string $data to store data |
||
220 | * @param boolean $para to store True/False |
||
221 | * |
||
222 | * @return string |
||
223 | */ |
||
224 | public function onReceiver($data, $para) |
||
229 | |||
230 | /** |
||
231 | * To Call Search Class |
||
232 | * |
||
233 | * @param string $data to store data |
||
234 | * |
||
235 | * @return string |
||
236 | */ |
||
237 | public function onSearch($data) |
||
242 | |||
243 | /** |
||
244 | * To Call Compose Class |
||
245 | * |
||
246 | * @param string $data to store data |
||
247 | * |
||
248 | * @return string |
||
249 | */ |
||
250 | public function onCompose($data) |
||
255 | |||
256 | /** |
||
257 | * To Call Reply Class |
||
258 | * |
||
259 | * @param string $data to store data |
||
260 | * |
||
261 | * @return string |
||
262 | */ |
||
263 | public function onReply($data) |
||
268 | |||
269 | /** |
||
270 | * To Call Online Class |
||
271 | * |
||
272 | * @param ConnectionInterface $conn To store client details |
||
273 | * |
||
274 | * @return void |
||
275 | */ |
||
276 | public function onClose(ConnectionInterface $conn) |
||
282 | |||
283 | /** |
||
284 | * To Show error due to any problem occured |
||
285 | * |
||
286 | * @param ConnectionInterface $conn To store client details |
||
287 | * @param \Exception $e To store exception |
||
288 | * |
||
289 | * @return void |
||
290 | */ |
||
291 | public function onError(ConnectionInterface $conn, \Exception $e) |
||
296 | |||
297 | } |
||
298 |
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.