Example #1
0
 protected function _redirectToRoom()
 {
     if (Dura_Class_RoomSession::isCreated()) {
         Dura::redirect('room');
     }
 }
Example #2
0
 protected function _createRoom()
 {
     $userName = Dura::user()->getName();
     $userId = Dura::user()->getId();
     $userIcon = Dura::user()->getIcon();
     $roomHandler = new Dura_Model_RoomHandler();
     $roomModel = $roomHandler->create();
     $roomModel->name = $this->input['name'];
     $roomModel->update = time();
     $roomModel->limit = $this->input['limit'];
     $roomModel->host = $userId;
     $roomModel->language = $this->input['language'];
     $users = $roomModel->addChild('users');
     $users->addChild('name', $userName);
     $users->addChild('id', $userId);
     $users->addChild('icon', $userIcon);
     $users->addChild('update', time());
     if (Dura::$language != $this->input['language']) {
         $langFile = DURA_TRUST_PATH . '/language/' . $this->input['language'] . '.php';
         Dura::$catalog = (require $langFile);
     }
     $talk = $roomModel->addChild('talks');
     $talk->addChild('id', md5(microtime() . mt_rand()));
     $talk->addChild('uid', 0);
     $talk->addChild('name', $userName);
     $talk->addChild('message', "{1} logged in.");
     $talk->addChild('icon', '');
     $talk->addChild('time', time());
     $id = md5(microtime() . mt_rand());
     if (!$roomHandler->save($id, $roomModel)) {
         throw new Exception(t("Data Error: Room creating failed."));
     }
     Dura_Class_RoomSession::create($id);
     Dura::redirect('room');
 }
Example #3
0
 protected function _logout()
 {
     $userName = Dura::user()->getName();
     $userId = Dura::user()->getId();
     $userOffset = 0;
     foreach ($this->roomModel->users as $user) {
         if ($userId == (string) $user->id) {
             break;
         }
         $userOffset++;
     }
     unset($this->roomModel->users[$userOffset]);
     if (count($this->roomModel->users)) {
         $this->_npcLogout($userName);
         if ($this->_isHost()) {
             $this->_moveHostRight();
         }
         $this->roomHandler->save($this->id, $this->roomModel);
     } else {
         $this->roomHandler->delete($this->id);
     }
     Dura_Class_RoomSession::delete();
     Dura::redirect('lounge');
 }