Esempio n. 1
0
 public static function out($gateway = null)
 {
     $asyncProtocol = '';
     if (empty(self::$_arrProtocol)) {
         return;
     }
     if (defined('JSON_PROTOCOL') && JSON_PROTOCOL > 0) {
         #测试的时候返回的下行是json格式
         foreach (self::$_arrProtocol as $protocol) {
             if ($protocol['cmd0'] == 7 || $protocol['cmd0'] == 8) {
                 $asyncProtocol[$protocol['player_id']] .= self::decode($protocol['player_id'], $protocol['cmd0'], $protocol['cmd1'], $protocol['cmd2'], $protocol['data']);
             }
             echo json_encode($protocol);
             //                Com_Log::write("json_out.".$protocol['player_id'],var_export($protocol,true));
         }
     } else {
         foreach (self::$_arrProtocol as $protocol) {
             //            Com_Log::write('out_protocol.'.$protocol['player_id'],"protocol:".var_export($protocol,true));
             //                Com_Log::write("player_upgrade.".$protocol['player_id'],"pro:".var_export($protocol,true));
             if ($protocol['cmd0'] == 7 || $protocol['cmd0'] == 8) {
                 $asyncProtocol[$protocol['player_id']] .= self::decode($protocol['player_id'], $protocol['cmd0'], $protocol['cmd1'], $protocol['cmd2'], $protocol['data']);
             } else {
                 if (isset($_GET['debug']) && $_GET['debug'] == 1) {
                     echo "<pre>";
                 }
                 echo self::decode($protocol['player_id'], $protocol['cmd0'], $protocol['cmd1'], $protocol['cmd2'], $protocol['data']);
                 if (isset($_GET['debug']) && $_GET['debug'] == 1) {
                     echo "<pre>";
                 }
             }
         }
     }
     self::$_arrProtocol = array();
     //清空协议
     if (!empty($asyncProtocol)) {
         foreach ($asyncProtocol as $player_id => $protocol) {
             Game_AsyncProtocol::getInstance()->rsync_protocol($player_id, $protocol, $gateway);
         }
     }
 }