示例#1
0
 public function checkLogin()
 {
     if (!$this->uid) {
         throw new common\error('错误的用户id');
     }
     $uid = common\connection::getConnection()->getUid($this->fd);
     if (empty($uid)) {
         throw new common\error('非法请求.');
     }
 }
示例#2
0
 public function onShutdown()
 {
     Debug::debug("Shutdown server over...\n");
     common\connection::getConnection()->clear();
 }
示例#3
0
 private static function gameXSY()
 {
     //铜钟、芒果、橙子全中
     $anteList = self::getAnteList();
     if (empty($anteList)) {
         return;
     }
     $useranteModel = self::getModel('useranteModel');
     $userModel = self::getModel('userModel');
     $rewardName1 = 'ring';
     $rewardRate1 = ZConfig::getField('item', $rewardName1);
     $rewardName2 = 'mango';
     $rewardRate2 = ZConfig::getField('item', $rewardName2);
     $rewardName3 = 'orange';
     $rewardRate3 = ZConfig::getField('item', $rewardName3);
     foreach ($anteList as $item) {
         if (!$item['uid']) {
             continue;
         }
         $score = 0;
         $sucess = false;
         if ($anteVal1 = $item[$rewardName1]) {
             $score += $anteVal1 * $rewardRate1;
         }
         if ($anteVal2 = $item[$rewardName2]) {
             $score += $anteVal2 * $rewardRate2;
         }
         if ($anteVal3 = $item[$rewardName3]) {
             $score += $anteVal3 * $rewardRate3;
         }
         if (!empty($score)) {
             $sucess = true;
             $useranteModel->updAnteById($item['id'], array('score' => $score), $item);
             $userModel->updUserCoinById($item['uid'], array('coin' => $score));
         }
         $uInfo = $userModel->getUserById($item['uid']);
         //send
         $fd = common\connection::getConnection()->get($uInfo['id'])['fd'];
         common\connection::sendOne($fd, self::$CMDsendScore, array('coin' => $uInfo['coin'], 'sucess' => $sucess, 'getScore' => $score));
     }
 }