Пример #1
0
 /**
  * Process close request. Find user chat, remove user from chat and send message
  * to other users in this chat
  *
  * @access public
  * @param $rid
  */
 private function closeRequest($rid)
 {
     //get user for closed connection
     $requestUser = $this->cm->getUserByRid($rid);
     $chat = $this->cm->getUserChat($rid);
     //remove user from chat room
     $this->cm->removeUserFromChat($rid);
     //send notification for other users in this chat
     $users = $chat->getUsers();
     $response = array('type' => 'close', 'data' => ['user' => $requestUser]);
     foreach ($users as $user) {
         $conn = $this->clients[$user->getRid()];
         $conn->send(Json::encode($response));
     }
 }