/** * 把任务处理放到预处理队列 * @Param $player_id 玩家ID */ public function async_send_old_account_login_reward($player_id, $user_account, $session_id) { $data['player_id'] = $player_id; $data['account'] = $user_account; $data['session_id'] = $session_id; return Com_Queued::send('send_old_account_login_reward', json_encode($data)); }
public function push_sys_notice($player_id, $func_id, $sub_func_id, $replace_info, $val = 0, $need_broadcas = 0) { $data['player_id'] = $player_id; $data['func_id'] = $func_id; $data['sub_func_id'] = $sub_func_id; $data['replace_info'] = $replace_info; $data['val'] = $val; $data['need_broadcas'] = $need_broadcas; //return $this->do_sys_notice(json_encode($data)); return Com_Queued::send($this->_sys_notice_channel, json_encode($data)); }
/** * 发布一个动态数据到消息队列中 * * @param unknown_type $func * @param unknown_type $dataArr 动态类型 1客栈 ... 后续定义 * @param unknown_type $type 动态内容 暂时传入文本数据 之后会收数组组装特定格式 * @param unknown_type $nowTime 动态时间 * @return unknown */ public function publish_data($func, $dataArr, $type, $nowTime, $ip = '') { $typeArr = array('active', 'login', 'level'); if (empty($dataArr)) { return true; } if (!in_array($type, $typeArr)) { return true; } return Com_Queued::send($this->dclogChannel, json_encode(array('func' => $func, 'dataArr' => $dataArr, 'type' => $type, 'time' => $nowTime, 'ip' => $ip))); }
/** * 异步推送协议 * @param $player_id * @param $raw_data 已经封装好的协议 * @return unknown */ public function rsync_protocol($player_id, $raw_data, $client_ip = null) { if (empty($client_ip)) { if (isset($_GET['debug']) && $_GET['debug'] == 1) { $client_ip = GATEWAY_IP; } else { $client_ip = Com_System::get_client_ip(); // || $client_ip == '127.0.0.1' if (empty($client_ip)) { $client_ip = GATEWAY_IP; } } } $channel_seq = Com_System::get_queue_channel_seq($player_id, 6); return Com_Queued::send($this->_channel . "_" . $channel_seq, json_encode(array('player_id' => $player_id, 'client_ip' => $client_ip, 'data' => base64_encode($raw_data)))); }
/** * 异步回调方法 * * @param unknown_type $className 类名 * @param unknown_type $classType 类类型 game, data, 空则表示全名 * @param unknown_type $function 方法名 * @param unknown_type $params 参数数组 * @return unknown */ public static function asyn_call_func($className, $classType, $function, $params) { $call = array(); if ($classType == 'game') { $class['class'] = TenYear::game_name($className); } elseif ($classType == 'data') { $class['class'] = TenYear::data_name($className); } else { $class['class'] = $className; } $class['function'] = $function; $class['params'] = $params; return Com_Queued::send(self::$asynCallQueue, json_encode($class)); }
/** * 把任务处理放到预处理队列 * @Param $player_id 玩家ID */ public function async_trigger_login_times($player_id) { $data['player_id'] = $player_id; return Com_Queued::send('async_update_login_times', json_encode($data)); }
public function async_deal_event_log($event_log_info) { return Com_Queued::send($this->_deal_event_log_channel, json_encode($event_log_info)); }
public function async_trigger_guide_task($player_id, $type, $add_num, $target_type = 0) { $data['player_id'] = $player_id; $data['type'] = $type; $data['target_type'] = $target_type; $data['add_num'] = $add_num; # 获取异步处理队列需要用的频道分割序号 $channel_seq = Com_System::get_queue_channel_seq($player_id, 12); return Com_Queued::send($this->_deal_guide_task_transfer_data_channel . "_" . $channel_seq, json_encode($data)); }
public function async_online_stat($data) { return Com_Queued::send('async_online_stat', json_encode($data)); }
public function push($log_string) { return Com_Queued::send($this->_channel, $log_string); }
public function sys_add_union_log($player_id, $union_id, $code, $arr_replace = array(), $log_type = 1) { $data['player_id'] = $player_id; $data['union_id'] = $union_id; $data['code'] = $code; $data['arr_replace'] = $arr_replace; $data['log_type'] = $log_type; return Com_Queued::send($this->_sys_add_union_log, json_encode($data)); }
/** * 第四步 推送给腾讯 */ public function pushTencent($data) { $data['time'] = time(); $data['player_id'] = $this->player_id; $data['info'] = array('token_id' => $this->auth['token']); foreach (array('payitem', 'billno', 'zoneid', 'amt', 'payamt_coins') as $key) { $data['info'][$key] = $this->auth[$key]; } return Com_Queued::send('tencent_pay', json_encode($data)); // $this->record($data); }
/** * 把任务处理放到预处理队列 * @param $player_id * @param $task_type * @param $target * @param $num */ public function async_trigger_union_task($player_id, $task_type, $target, $num = 1, $union_id = null) { $player_id = intval($player_id); #获取玩家公会ID,验证公会信息 if (is_null($union_id)) { $union_id = $this->get_data('Player')->get_player_info($player_id, 'union_id'); } if ($union_id < 1) { return; } $data['player_id'] = $player_id; $data['task_type'] = $task_type; $data['target'] = $target; $data['num'] = $num; return Com_Queued::send('async_update_union_task', json_encode($data)); }
/** * @param $player_id * @param $player_info array('exp','level','level_exp','after_hero_hole') 使用升级的时候传下这几个数据 * @return unknown */ public function publish_upgrade($player_id, $player_info) { $data['player_id'] = $player_id; $data['exp'] = $player_info['exp']; $data['level'] = $player_info['level']; $data['level_exp'] = $player_info['level_exp']; $data['career_type'] = $player_info['career_type']; $data['after_hero_hole'] = $player_info['after_hero_hole']; $data['privilege_level'] = $player_info['privilege_level']; $data['name'] = $player_info['name']; $data['vip'] = $player_info['vip']; $data['union_id'] = $player_info['union_id']; // Com_Log::write('xgame.upgrade', "publish_upgrade:\t".json_encode($data)); $gateway = Com_System::get_client_ip(); if (empty($gateway)) { $data['gateway'] = GATEWAY_IP; } else { $data['gateway'] = $gateway; } # 获取异步处理队列需要用的频道分割序号 $channel_seq = Com_System::get_queue_channel_seq($player_id, 11); return Com_Queued::send($this->upgradeChannel . "_" . $channel_seq, json_encode($data)); }
/** * 异步执行 * * @param unknown_type $data * @return unknown */ protected function active_wait($data) { $data['exec'] = 1; $message = json_encode($data); return Com_Queued::send($this->init_queue, $message); }
public function publish_data($player_id, $act, $params) { // Com_Log::write('data_center_publish_data',json_encode(array('player_id'=>$player_id,'act'=>$act,'params'=>$params))); return Com_Queued::send($this->_data_center_channel, json_encode(array('player_id' => $player_id, 'act' => $act, 'params' => $params))); }
public function publish_attr($player_id, $data) { # 获取异步处理队列需要用的频道分割序号 $channel_seq = Com_System::get_queue_channel_seq($player_id, 141); return Com_Queued::send($this->_sync_player_attr . "_" . $channel_seq, json_encode($data)); }
/** * 队列插入回调方法的参数 * @param $params */ public function publish_data($params) { Com_Queued::send($this->queue_37wan_chatmonitor, json_encode($params)); // Com_Log::write('uploadDataError',json_encode($params)); }
/** * $update_type 1累加 2赋值 3小于等于(一般用于排名) * $this->get_game('UnionAchieve')->async_trigger_union_achieve($player_id,$type,$num,$update_type); * @param unknown $player_id * @param unknown $type * @param unknown $num * @param number $update_type * @return unknown */ public function async_trigger_union_achieve($player_id, $type, $num, $update_type = 1, $union_id = null) { $data["player_id"] = $player_id; $data["task_type"] = $type; $data["num"] = $num; $data["update_type"] = $update_type; if (is_null($union_id)) { $playerInfo = $this->get_data('Player')->get_player_info($player_id, array("union_id")); $union_id = intval($playerInfo['union_id']); } if ($union_id == 0) { return false; } $data["union_id"] = $union_id; //return $this->trigger_union_achieve(json_encode($data)); return Com_Queued::send("union_achieve", json_encode($data)); }
/** * 新插入一个队列,内容为回调方法需要传入的数据 * @param $params * @return bool */ private function publish_data($params) { // Com_Log::write("uploadDataError","publish_data ".$params); return Com_Queued::send($this->tencent_compass_queue, $params); }
public function sys_clear_union_apply($agree_player_id) { $data['agree_player_id'] = $agree_player_id; return Com_Queued::send($this->_sys_clear_union_apply, json_encode($data)); }
public function async_deal_challenge_battle($player_id, $battle_seq, $winner_player_id, $loser_player_id) { $battle_info = array('player_id' => $player_id, 'battle_seq' => $battle_seq, 'winner_player_id' => $winner_player_id, 'loser_player_id' => $loser_player_id); return Com_Queued::send($this->_deal_challenge_battle_channel, json_encode($battle_info)); }
/** * 把任务处理放到预处理队列 * @Param $player_id 玩家ID * @Param $vip_level VIP等级 */ public function async_trigger_update_sweep_state($player_id, $vip_level) { $vip_level = intval($vip_level); #获取VIP配置表副本限制 $vip_table = Cache_VipLevelLimit::getInstance()->get_limit_info_unrelated_to_vip_level(10008); if ($vip_table['vip_level'] < 1 || $vip_level < $vip_table['vip_level']) { return FALSE; } $data['player_id'] = $player_id; $data['vip_level'] = $vip_level; return Com_Queued::send('async_update_sweep_state', json_encode($data)); }
/** * 腾讯 应用发货通知 * @param int $player_id 玩家id * @param int * @param array $arr_replace */ public function pushToTencent($data) { if (empty($data)) { return; } $data = json_decode($data, true); file_put_contents(PROJECT_ROOT . '/uuzudo.log', var_export(array('q1', $data), true) . "\n", FILE_APPEND); if (!isset($data['time'])) { return false; } $current_time = time(); $sleep_seconds = $data['time'] + $this->pushAppTime - $current_time; if ($sleep_seconds <= 0) { $player_id = $data['player_id']; $key_arr = array('openid', 'openkey', 'pf', 'pfkey'); $session_id = $this->get_data('Player')->get_player_info($player_id, 'session_id'); $session_info = $this->get_game('Online')->get_session($session_id); foreach ($key_arr as $key) { $params[$key] = $session_info[$key]; } //$params = $this->redis()->hash_get($this->user_tencent_table. ':'. $player_id, $key_arr); if (empty($params)) { printf("token_id=%s, billno=%s, zoneid=%s, payitem=%s of tencent_info empty!\n", $data['info']['token_id'], $data['info']['billno'], $data['info']['zoneid'], $data['info']['payitem']); return -1; } $params['provide_errno'] = $data['ret']; $params['ts'] = $current_time; foreach (array('payitem', 'token_id', 'billno', 'zoneid', 'amt', 'payamt_coins') as $key) { $params[$key] = $data['info'][$key]; } //向腾讯应用发请求 confirm $res = $this->api($this->pushAppConfirmApi, $params, 'post', 'https'); file_put_contents(PROJECT_ROOT . '/uuzudo.log', var_export(array('q2', $res, $params), true) . "\n", FILE_APPEND); if ($res['ret'] != 0) { $res = $this->api($this->pushAppConfirmApi, $params, 'post', 'https'); } //log $params['ret'] = $res['ret']; $params['msg'] = $res['msg']; $log_key = $this->log_key . ':' . date('Ymd', $current_time); $this->redis()->list_push($log_key, json_encode($params)); $this->redis()->expire($log_key, 86400 * 7); } else { Com_Queued::send('tencent_pay', json_encode($data)); sleep($sleep_seconds); } return true; }
/** * 把任务处理放到预处理队列 * @Param $player_id 玩家ID * @Param $cur_times 当前完成次数 * @Param $max_times 最大完成次数 * @Param $type 公会引导类型(1:福利2:悬赏3:巨炮4:科技5:商店6:活动) * @Param $sub_type 公会引导子类型(1:福利2:悬赏3:巨炮4:科技5:商店6:活动) */ public function async_trigger_union_guide($player_id, $cur_times, $max_times, $type, $sub_type) { $player_id = intval($player_id); $cur_times = intval($cur_times); $max_times = intval($max_times); if ($player_id < 1 || $cur_times < $max_times) { return; } $data['player_id'] = $player_id; $data['cur_times'] = $cur_times; $data['max_times'] = $max_times; $data['type'] = $type; $data['sub_type'] = $sub_type; return Com_Queued::send('async_update_union_guide', json_encode($data)); }
public function flush_cache($dbname = "setting") { Com_Cache::factory($dbname)->flush(); Com_Cache::factory("game")->flush(); Com_Queued::send("process", "restart"); }
/** * 写日志 * @param string $content */ public function log_write($data, $type = null) { #$content['table'] = $this->_table; if (isset($data['add_time'])) { $add_time = $data['add_time']; } else { $add_time = time(); } $content['table'] = $this->get_table_name($data['channel'], $add_time, $type); $content['data'] = $data; $result = Com_Queued::send($this->get_queue(), json_encode($content)); // $result = false; if (!$result) { Com_Log::write('xgame.all.error', "Queued send error..." . json_encode($content)); $fp = $this->get_log_fp(); if ($fp) { $content = $this->create_sql($content['table'], $data); fwrite($fp, $content); } } }
/** * 把邮件处理放到预处理队列 * @param unknown $player_id * @param unknown $title * @param unknown $content * @param unknown $attachment * @param number $channel * @param number $type 类型1系统 2公会 3GM工具 * @param number $bind_flag null 为不绑定 0为绑定 * @return unknown */ public function async_trigger_mail($player_id, $title, $content, $attachment = array(), $sender = '', $type = 1, $cmd_id = 0, $bind_flag = null) { $expire_day = 3; if ($type == 1) { $expire_day = 7; } if ($type == 3) { $bind_flag = 0; } if (empty($title) || empty($content) || empty($sender)) { return false; } if (!$player_id) { return false; } Com_Log::debug_write('async_trigger_mail_test', "player_id={$player_id},{$title}=" . json_encode($attachment)); if (!empty($attachment)) { $data = $this->add_extract_mail($player_id, $title, $content, $attachment, $sender, $expire_day, $type, $cmd_id, $bind_flag); } else { $data = $this->add_mail($player_id, $title, $content, $sender, $expire_day, $type); } if ($data) { Com_Log::debug_write('async_trigger_mail', json_encode($data)); #$ret = $this->do_async_trigger_mail(json_encode($data)); $ret = Com_Queued::send($this->_deal_mail_transfer_data, json_encode($data)); } return $ret; }
public function sendSysMail($dataArr, $type, $nowTime, $ip) { global $AccountArr; if (!isset($AccountArr)) { echo "not require AccountArr\n"; $filename = DATA_PATH . '/cache/ceshi_user.cache'; if (file_exists($filename)) { echo "require AccountArr\n"; require_once $filename; } else { $AccountArr = array(); } } $account = $dataArr['account']; $player_id = $dataArr['player_id']; if (!empty($AccountArr) && isset($AccountArr[SERVER_ID])) { $dataArr = $AccountArr[SERVER_ID]; if (in_array($account, $dataArr['account'])) { $mail["mail_type"] = 0; $mail["sender"] = 0; $mail["sender_name"] = Language_Error::get_language_error('ERROR_MAIL_3'); $mail["receiver"] = $player_id; $mail["title"] = $dataArr['title']; $mail["content"] = $dataArr['content']; $mail["silver"] = 0; $mail["gold"] = 0; if (!empty($dataArr['props'])) { $props = explode(';', $dataArr['props']); foreach ($props as $prop) { $propArr = explode(':', $prop); if (!isset($propArr[2])) { $propArr[2] = 0; } $mail["prop"][] = array("prop_id" => $propArr[0], "item_num" => $propArr[1], "quality" => $propArr[2]); } $mail["attachment"]["prop"] = $mail["prop"]; } $mail["attachment"] = array(); if ($mail["mail_type"] === 0) { if (isset($mail["silver"])) { if ($mail["silver"] > 0) { $mail["attachment"]["silver"] = $mail["silver"]; } unset($mail["silver"]); } if (isset($mail["gold"])) { if ($mail["gold"] > 0) { $mail["attachment"]["gold"] = $mail["gold"]; } unset($mail["gold"]); } if (isset($mail["prop"])) { if (!empty($mail["prop"])) { $mail["attachment"]["prop"] = $mail["prop"]; } unset($mail["prop"]); } if (count($mail["attachment"]) > 0) { $mail["attachment_state"] = 1; } } //file_put_contents(PROJECT_ROOT.'/uuzudo.log',var_export(array('sendMessage',$account,$op,$nowTime,$ip),true)."\n",FILE_APPEND); Com_Queued::send("mail", Com_Serialize::serialize($mail)); } } }
public function sys_update_like_friend_data($player_id, $friend_id, $news_id, $name) { $data['friend_id'] = $friend_id; $data['player_id'] = $player_id; $data['name'] = $name; $data['news_id'] = $news_id; #return $this->do_sys_set_data(json_encode($data));//临时测试 return Com_Queued::send($this->_sys_like_friend_news, json_encode($data)); }