コード例 #1
0
ファイル: Protocol.php プロジェクト: bluefan/phpsource
 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);
         }
     }
 }
コード例 #2
0
ファイル: AsyncProtocol.php プロジェクト: bluefan/phpsource
/**
 * 处理异步推送的协议
 * Created by PhpStorm.
 * User: chengt
 * Date: 14-5-8
 * Time: 下午8:26
 */
require dirname(__FILE__) . '/../global.php';
TenYear::getInstance();
ini_set('default_socket_timeout', -1);
Com_AdCache::factory()->set_timeout(0);
//$client_ip = array( //测试得机器
//    '192.168.1.228',
//    '192.168.1.224',
//    '192.168.1.24',
//    '192.168.1.121',
//    '192.168.1.136',
//    '192.168.1.165',
//    '192.168.1.155'
//);
//
//foreach($client_ip as $ip){
//    Com_GatewayClient::connect($ip);
//}
$process_seq = empty($argv[1]) ? 0 : $argv[1];
# 进程序号
Game_AsyncProtocol::getInstance()->register($process_seq);
echo "register chat receive \r\n";
echo "start receive \r\n";
//开始接收
Com_Queued::receive_all();
コード例 #3
0
ファイル: Reward.php プロジェクト: bluefan/phpsource
 /**
  * 加日志  在整个业务Commit后调用这个函数增加日志
  * @param bool $reward_flag true的时候输出 一种奖励框
  */
 public function add_reward_log($reward_flag = false, $func_id = 0, $show_msg = 1, $upgrade_async = true)
 {
     if (!empty($this->arrPlayerReward)) {
         $this->add_player_reward_log($upgrade_async);
     }
     if (!empty($this->arrPropLogs)) {
         $this->add_prop_reward_log($func_id);
     }
     if ($show_msg) {
         Game_GainMsg::out($this->player_id);
     }
     if ($reward_flag) {
         Protocol_Reward::out($func_id);
     } else {
         Protocol_Reward::clear();
     }
     if (!empty($this->protocol)) {
         Game_AsyncProtocol::getInstance()->rsync_protocol($this->player_id, $this->protocol);
     }
 }