Пример #1
0
 public function testRemoveUserFromChat()
 {
     $this->cm->addUser($this->rid, $this->userId);
     $chat = $this->cm->findChat($this->chatId, $this->rid);
     $this->cm->removeUserFromChat($this->rid);
     $this->assertEquals(0, sizeof($chat->getUsers()), 'Chat should not contains any users');
 }
Пример #2
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));
     }
 }