Example #1
0
 public static function doApi($client_id, $message)
 {
     // 获取客户端请求
     $data = json_decode($message, true);
     if (!$data) {
         return;
     }
     $re = array();
     $re['type'] = $data['type'];
     $st = 0;
     if ($data['type'] == 'login') {
         Login::doApi($data, $re);
         isset($re['uid']) && Gateway::bindUid($client_id, $re['uid']);
     } else {
         $uid = $data['uid'];
         $player = PlayerDao::getPlayer($uid);
         //            RedisUtil::lock($uid);
         if (!$data['uid'] || !$player) {
             $re['s'] = Constants::RESPONSE_NO_PLAYER;
             Gateway::sendToClient($client_id, json_encode($re));
             //                RedisUtil::unlock($uid);
             return;
         }
         $re['s'] = Constants::RESPONSE_SUCCESS;
         switch ($data['type']) {
             case 'test':
                 $st = Progress::doApi($player, $data, $re, $client_id);
                 break;
             case 'jt':
                 JoinTable::doApi($player, $data, $re);
                 break;
             case 'll':
                 Landlord::doApi($player, $data, $re);
                 break;
             case 'play':
                 $st = Play::doApi($player, $data, $re);
                 break;
             case 'chgSt':
                 ChgPlaySt::doApi($player, $data, $re);
                 break;
             default:
                 $re['s'] = Constants::RESPONSE_FAIL;
                 break;
         }
     }
     if ($st != 1) {
         Gateway::sendToClient($client_id, json_encode($re));
     }
     //        RedisUtil::unlock($uid);
 }
Example #2
0
 /**
  * 抢地主操作超时
  */
 public function landlordOverTime()
 {
     $status = $this->nextLandlord(0, 0);
     TableDao::addTable($this->tableId, $this);
     $re['type'] = 'll';
     switch ($status) {
         case Constants::LANDLORD_ENSURE:
             Landlord::sendInfo($this, $re);
             break;
         case Constants::LANDLORD_NEXT_CHOOSE:
             Landlord::sendNextInfo($this, $re);
             break;
         case Constants::LANDLORD_RE_JOIN:
             $this->rmTable();
             break;
     }
 }