1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374 |
- <?php
- use \GatewayWorker\Lib\Gateway;
- class Events
- {
-
- public static function onConnect($client_id)
- {
-
- Gateway::sendToClient($client_id, json_encode(array(
- 'type' => 'init',
- 'client_id' => $client_id
- )));
- }
-
-
- public static function onMessage($client_id, $message)
- {
- if(strpos($message,'get_state:')===0){
- $user_ids=explode(',',str_replace('get_state:','',$message));
- $u_state=array();
- foreach($user_ids as $user_id){
- $u_state[$user_id]=Gateway::isUidOnline('0:'.$user_id);
- }
- Gateway::sendToClient($client_id, json_encode(array(
- 'type' => 'get_state',
- 'u_state' => $u_state,
- )));
- }
- }
-
-
- public static function onClose($client_id)
- {
- }
- }
|