public function testProtocolSuccess() { $protocol = new Protocol(); $protocol->modality_id = 1; $protocol->name = "Rita 3cm Protocol"; $protocol->algorithm = "Some storage pattern"; $this->assertTrue($protocol->save()); }
/** * get the output * * @since 2.4.0 * * @return string */ public function getOutput() { $protocol = new Protocol($this->_request); $host = new Host($this->_request); $directory = new Directory($this->_request); /* collect output */ $output = $protocol->getOutput() . '://' . $host->getOutput(); if ($directory->getOutput() !== '/' && $directory->getOutput() !== '\\') { $output .= $directory->getOutput(); } return $output; }
function __construct() { parent::__construct(); $this->id = 0; $this->author = ''; $this->name = ''; $this->size = 0; $this->desc = ''; $this->turl = ''; $this->mpurl = ''; $this->mcurl = ''; $this->miurl = ''; $this->mmurl = ''; $this->_index = 0; $this->icontact = 0; $this->iicon = 0; $this->imms = 0; $this->c_time = ''; $this->pnum = 0; $this->intro = ''; $this->starlevel = ''; $this->kernel = 0; $this->type = 0; $this->effect = ''; $this->font_style = ''; $this->keyguard_style = ''; $this->prev_imgs = array(); $this->ad = 0; $this->adicon = ''; $this->adurl = ''; }
/** * 输出协议 * @param $player_id */ public static function out($player_id) { if (isset(self::$_gain_msg[$player_id]) && !empty(self::$_gain_msg[$player_id])) { Protocol::input($player_id, 8, 7, 740, self::$_gain_msg[$player_id]); unset(self::$_gain_msg[$player_id]); } }
public function router($cmd0, $cmd1, $cmd2, $player_id, $arr_param) { global $arrParam, $arrAuthUser, $logHandler; $arrAuthUser['player_id'] = $player_id; $arrParam = $arr_param; $class = 'S2P_' . $cmd1; $include_file = ACTION_PATH . "/S2P/S2P_{$cmd1}.php"; if (is_file($include_file)) { require $include_file; try { //调用对应指令函数 $obj = new $class(); $exec_cmd2 = 'CMD2_' . $cmd2; if (ECONOMY_LOG_SWITCH === TRUE) { $logHandler['logger'] = new Com_Logger($cmd0, $cmd1, $cmd2, $player_id); } call_user_func_array(array($obj, $exec_cmd2), array()); $protocols = Protocol::get_protocol(); Protocol::out(); Statistic::report($cmd0, $cmd1, $cmd2, $arrAuthUser, $arrParam, 1, 'exec fun success', $protocols); if (ECONOMY_LOG_SWITCH === TRUE) { $logHandler['logger']->flush_log(); } exit; } catch (Exception $e) { //有异常 $msg = json_decode($e->getMessage(), true); $error = "Exception: " . $e->getFile() . " line:" . $e->getLine() . " error code " . $msg['error']['code']; Statistic::report($cmd0, $cmd1, $cmd2, $arrAuthUser, $arrParam, 0, $error); Protocol::input($player_id, 8, 7, 742, array(0 => array($msg['error']))); Protocol::out(); exit; } } }
public function route($event, Message $request, Message $response = null) { if ($this->upgraded) { switch ($request->getOpCode()) { case Request::OPCODE_CTRL_CLOSE: $this->sendClose($request); break; case Request::OPCODE_CTRL_PING: $this->sendPong($request); break; case Request::OPCODE_CTRL_PONG: break; case Request::OPCODE_NCTRL_TEXT: case Request::OPCODE_NCTRL_BIN: parent::route($event, $request, new Response()); break; default: throw new \Exception("Unknown opcode " . var_export($request->getOpCode(), 1)); } } else { $response = new \Phasty\Server\Http\Response(); $response->setWriteStream($request->getReadStream()); $hash = $this->getAcceptHash($request->getHeader("Sec-WebSocket-Key")[0]); $origin = $request->getHeader("Origin")[0]; $location = "ws://" . $request->getHeader("Host")[0] . $request->getPath(); $response->setCode(101)->setHeader("Upgrade", "websocket")->setHeader("Connection", "Upgrade")->setHeader("Origin", $origin)->setHeader("Sec-WebSocket-Accept", $hash); if ($request->hasHeader("Sec-WebSocket-Protocol")) { $request->setHeader("Sec-WebSocket-Protocol", "chat"); } $response->on("sent", function () use($request) { $this->upgraded = true; $request->trigger("dispatched", ["nextProtocol" => $this]); })->send(); } }
public function run($player_id, $s_task_id) { $player_info = $this->get_data('Player')->get_player_info($player_id, array('level')); $level = $player_info['level']; // $task_id = $this->get_random_chain_task_id($level,0); $task_id = $s_task_id; $data = array(); if (!empty($task_id)) { $arr_player_task = $this->get_game('TaskChain')->get_init_chain_val($player_id, $task_id, 1); $result = $this->get_data('PlayerTask')->set_task_info($player_id, array('chain_val' => $arr_player_task['chain_val'], 'target_val' => $arr_player_task['target_val'])); if ($result) { $result = $this->get_data('PlayerTask')->set_chain_task_count($player_id); } if ($result) { $data = $this->get_game('TaskChain')->get_chain_task_list($player_id, $arr_player_task); Protocol::input($player_id, 8, 10, 1025, $data); } } Protocol::out(); if ($result) { echo 'success'; } else { echo 'error'; } exit; }
public static function run($string, $udid, $email) { $ret = DeviceControl::sendTo($string, $email, $udid, $email); $array = Protocol::decode($ret); if (isset($array["result"])) { $ret_string = $array["result"]; $data = $array["result"]; $json = json_decode($string, true); $mid = $json["params"]["mid"]; $db = Db::init(); switch ($json["method"]) { case "TurnOn": _Notify::add($mid, $_GET["u"], "开启"); $stat = 1; break; case "TurnOff": _Notify::add($mid, $_GET["u"], "关闭"); $stat = 0; break; default: $stat = 0; } $db->query("update device set stat={$stat} where mid='{$mid}'"); } else { if (isset($array["data"])) { $ret_string = $data; } else { $ret_string = $ret; //echo Error::getRetString(-1); } } return $ret_string; }
public static function out($player_id, $player_info = null) { if (!empty(self::$_guide_list)) { $out = array(); $logs = array(); $data = self::get_data('PlayerDetail')->get_player_detail($player_id, 'guide'); foreach (self::$_guide_list as $guide) { $out[$guide['guide_id']] = array('guide_id' => $guide['guide_id'], 'step' => $guide['step']); $logs[$guide['guide_id']] = array('type' => 1, 'task_id' => $guide['guide_id'], 'step' => $guide['step'], 'status' => 0); $data[$guide['guide_id']] = 1; } $result = self::get_data('PlayerDetail')->update_player_detail($player_id, array('guide' => $data)); if (!$result) { return; } if (!IS_FRONT || defined('FROM_GATEWAY')) { $cmd0 = 8; } else { $cmd0 = 3; } // Com_Log::write('guide_'.$player_id,var_export($out,true)); Protocol::input($player_id, $cmd0, 7, 787, array(0 => $out)); if (empty($player_info) || !isset($player_info['level']) || !isset($player_info['vip'])) { $player_info = self::get_data('Player')->get_player_info($player_id, array('level', 'vip')); } Log_Guide::getInstance()->add_multi_guide_log($player_id, $player_info['level'], $player_info['vip'], $logs); self::$_guide_list = null; } }
public function sync($data) { $arr_account = file_get_contents(CACHE_PATH . "/server3.txt"); $arr_account = json_decode($arr_account, true); $player_id = $data['player_id']; $user_account = $data['user_account']; if (!$player_id || !$user_account) { return; } if (isset($arr_account[$user_account])) { if ($arr_account[$user_account]['level'] >= 55) { // 生成奖励邮件附件信息 $attachment = array(); $attachment[] = array("prop_id" => 95015, "prop_num" => 1); // 邮件发送 $phrase_config = Cache_FuncPhraseConfig::getInstance()->get_phrase_config_info(8005); $re = $this->get_game('Mail')->async_trigger_mail($player_id, $phrase_config['title'], $phrase_config['content'], $attachment, $phrase_config['sender'], 1, 108); $this->write_check($re); Protocol::out(); } if ($arr_account[$user_account]['sum_fpower'] >= 80000) { // 生成奖励邮件附件信息 $attachment = array(); $attachment[] = array("prop_id" => 95014, "prop_num" => 1); // 邮件发送 $phrase_config = Cache_FuncPhraseConfig::getInstance()->get_phrase_config_info(8006); $re = $this->get_game('Mail')->async_trigger_mail($player_id, $phrase_config['title'], $phrase_config['content'], $attachment, $phrase_config['sender'], 1, 108); $this->write_check($re); Protocol::out(); } } }
/** * 上报统计数据 * * @param string $module * @param string $interface * @param bool $success * @param int $code * @param string $msg * @param string $report_address * @return boolean */ public static function report($module, $interface, $success, $code, $msg, $report_address = '') { $report_address = $report_address ? $report_address : '127.0.0.1:55656'; if (isset(self::$timeMap[$module][$interface]) && self::$timeMap[$module][$interface] > 0) { $time_start = self::$timeMap[$module][$interface]; self::$timeMap[$module][$interface] = 0; } else { if (isset(self::$timeMap['']['']) && self::$timeMap[''][''] > 0) { $time_start = self::$timeMap['']['']; self::$timeMap[''][''] = 0; } else { $time_start = microtime(true); } } $cost_time = microtime(true) - $time_start; $bin_data = Protocol::encode($module, $interface, $cost_time, $success, $code, $msg); if (extension_loaded('swoole')) { if (!self::$client || !self::$client->isConnected()) { self::$client = new swoole_client(SWOOLE_TCP, SWOOLE_SOCK_SYNC); list($ip, $port) = explode(':', $report_address); self::$client->connect($ip, $port); } self::$client->send($bin_data); self::$client->close(); self::$client = null; } else { return self::sendData($report_address, $bin_data); } }
/** * 道具变更下行协议 * @param $player_id * @param $change_prop 二维数组 传进去player_prop的内容 * 如果是位置变更 要加上 ['from_item_position'] 原始位置 ['from_grid'] 原始格子数 * player_prop里面的 item_position 赋值为新的位置编号 grid 赋值为新的格子编号 * @param $error_code 0 失败 1成功 * @param $cmd0 3 直接返回给flash 8 通过异步返回 * @param $flag 协议输出格式 0 直接输出 1 标志为粘包 2返回协议内容 3 附加粘包 * */ public static function prop_806($player_id, $change_prop, $func_id = 0, $error_code = 1, $cmd0 = 3, $flag = 3) { //后面三个参数不用了 $data['type'] = 1; $data['result'] = $error_code; $data['box'] = array(); if (!empty($change_prop)) { foreach ($change_prop as $prop) { $tmp_prop = array(); if ($prop['item_num'] <= 0) { //道具数量等于0的时候 只给位置信息就好了 $tmp_prop['item_position'] = $prop['item_position']; $tmp_prop['grid'] = $prop['grid']; } else { # 要求只有新发的道具的from_item_position=0,老道具都要求非0 $tmp_prop = $prop; $tmp_prop['from_item_position'] = $prop['from_item_position']; } $data['box'][] = Struct_Prop::get_item_box_operate_struct($tmp_prop); } } $data['func_id'] = $func_id; if (!IS_FRONT) { Protocol::input($player_id, 8, 8, 806, $data); Protocol::out(); } else { if (defined('FROM_GATEWAY')) { $cmd0 = 8; } Protocol::input($player_id, $cmd0, 8, 806, $data); } }
/** * @Purpose: * 异步更新公会引导状态 * @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_update_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); $type = intval($type); $sub_type = intval($sub_type); if ($player_id > 0 && $cur_times >= $max_times && $type > 0 && $sub_type > 0) { #获取玩家公会引导天数据 $ug_data = $this->get_data('UnionGuide')->get_union_guide_info($player_id, 'ug', 'day'); if ($ug_data[$type . $sub_type] != 1) { $ug_data[$type . $sub_type] = 1; $this->start_trans(); #更新公会引导天数据 $update_res = $this->get_data('UnionGuide')->update_union_guide_data($player_id, 'ug', $ug_data); if (!$update_res) { $this->throw_error('10104'); } $this->commit(); #主动更新Flash面板数据 Protocol::input($player_id, 8, 17, 1778, array($type, $sub_type, $ug_data[$type . $sub_type])); if (!IS_FRONT) { Protocol::out(); } } } }
/** * Shuts down the connection */ public function shutdown() { Services::getEvent()->fire($this, 'shutdown'); // Shutdown server connection if existant if (!feof($this->socket)) { $this->protocol->shutdownConnection(); } }
function __construct() { parent::__construct(); $this->name = 0; $this->iconUrl = ''; $this->url = ''; $this->size = ''; $this->intro = ''; }
public function doAction() { $userInfo_json = base64_decode($_POST['data']); $userInfo_array = json_decode($userInfo_json, true); $state = isset($userInfo_array['state']) ? $userInfo_array['state'] : ""; $ips = isset($userInfo_array['ips']) ? $userInfo_array['ips'] : ""; $data = array(); $res = array(); if (!empty($state) && !in_array($state, $this->state)) { $data['status'] = 8; exit; } else { $data['status'] = 0; } if ($state == 'open') { #开服 #Protocol::input(0, 7, 4, 514, array('type_id'=>1,'role_id'=>0)); #Protocol::out(); $res['status'] = 1; if ($this->get_data('Online')->set_server_state($res)) { $data['status'] = 1; } else { $data['status'] = 0; } } elseif ($state == 'close') { #关服维护 Protocol::input(0, 7, 4, 514, array('type_id' => 1, 'role_id' => 0)); Protocol::out(); $res['status'] = 0; if ($this->get_data('Online')->set_server_state($res)) { $data['status'] = 1; TenYear::getInstance(); $objSession = TenYear::getInstance('session'); $objSession->del_all_session(); } else { $data['status'] = 0; } } elseif ('write_ip' == $state) { #白名单 $res['write_ip'] = $ips; if ($this->get_data('Online')->set_server_state($res)) { $data['status'] = 1; } else { $data['status'] = 0; } } elseif ('black_id' == $state) { #黑名单 $res['black_id'] = $ips; if ($this->get_data('Online')->set_server_state($res)) { $data['status'] = 1; } else { $data['status'] = 0; } } echo json_encode($data); return; }
function __construct() { parent::__construct(); $this->id = ''; $this->name = ''; $this->fname = ''; $this->url = ''; $this->size = 0; $this->imgurl = ''; }
/** * Display the specified resource. * * @param int $id * @return Response */ public function show($id) { $protocol = Protocol::find($id); if (empty($protocol)) { return Redirect::route('protocol.index')->withError("Protocol not found"); } $protocol->combinations->load('PowerGenerator', 'NumericalModel'); return View::make('protocols.show', compact('protocol')); // }
public function doAction() { $userInfo_json = base64_decode($_POST['data']); $userInfo_array = json_decode($userInfo_json, true); $ban = array(); $result['data'] = $this->get_data('Player')->update_player_info($userInfo_array['player_id'], array('is_ban' => 3)); $result['status'] = 1; Protocol::input(0, 7, 4, 514, array('type_id' => 2, 'role_id' => $userInfo_array['player_id'])); Protocol::out(); echo json_encode($result); }
function __construct() { parent::__construct(); $this->id = ''; $this->name = ''; $this->fname = ''; $this->url = ''; $this->size = 0; $this->type = 0; $this->download_times = 0; }
protected function adult_remind($player_id, $status) { if ($status == 1) { $msg = Language_Message::make_message('10223'); $type = 1; } else { $msg = Language_Message::make_message('10224'); $type = 2; } Com_Log::write("do_timeer." . $player_id, "msg:" . var_export($msg, true)); Protocol::input($player_id, 8, 7, 755, array(0 => $msg, 1 => $type)); }
/** * @Purpose: * 通知C++新一天的优先公会活动 */ public function refresh_new_union_activities_p2c() { #获取公会ID列表 $union_id_list = $this->get_data('UnionInfo')->get_all_union_id(); if (Com_Array::is_good_arr($union_id_list)) { foreach ($union_id_list as $union_id => $val) { #同步活动数据到C++ $this->get_game('Union')->Sync_Union_msg($union_id, 0); Protocol::out(); } } }
/** * 功能图标变更下行协议 * @param $player_id * @param $func_id * @param $action_type: 0关闭,1开启 * */ public static function sync_func_data($player_id, $func_id, $action_type = 0, $func_config = null) { if (empty($func_config) || !is_array($func_config)) { $func_config = Cache_FuncConfig::getInstance()->get_func_config_info($func_id); } if ($action_type == 0) { # 告知Flash关闭功能 $out_741['funcs'][] = array('operate' => 2, 'func_id' => $func_config['func_id'], 'func_name' => $func_config['func_name'], 'open' => 1, 'pos' => $func_config['pos'], 'order' => $func_config['order']); } elseif ($action_type == 1) { # 告知Flash开启功能 $out_741['funcs'][] = array('operate' => 1, 'func_id' => $func_config['func_id'], 'func_name' => $func_config['func_name'], 'open' => 1, 'pos' => $func_config['pos'], 'order' => $func_config['order']); } Protocol::input($player_id, 8, 7, 741, $out_741); }
public function run($player_id, $s_task_id) { $arr_player_task = $this->get_data('PlayerTask')->get_task_info($player_id); $out = array(); $this->get_game('TaskMain')->do_guide_task($player_id, $s_task_id, 1, $arr_player_task, $out); $result = $this->get_data('PlayerTask')->set_task_info($player_id, $arr_player_task); Protocol::input($player_id, 8, 10, 1002, array(0 => $out)); if ($result) { echo 'success'; } else { echo 'error'; } exit; }
public static function msg($player_id, $code, $out_code = 0) { if (!IS_FRONT || defined('FROM_GATEWAY')) { $cmd0 = 8; } else { $cmd0 = 3; } if ($out_code > 0) { $msg = Language_Message::make_message($code, array(0 => array('rep_type' => 7, 'rep_val' => "-" . $out_code))); } else { $msg = Language_Message::make_message($code); } Protocol::input($player_id, $cmd0, 7, 742, array(0 => array($msg))); #提示采集成功 }
/** * 获得返回字符串 * * @param code 全局返回码 * @param results results值 */ public static function getRetString($code, $results = null) { $msg = "未知错误,错误代码({$code})"; switch ($code) { case 0: $msg = "ok"; break; case 1: $msg = "错误"; break; } if ($results != null) { return Protocol::encode(array("code" => $code, "msg" => $msg, "results" => $results)); } else { return Protocol::encode(array("code" => $code, "msg" => $msg)); } }
public static function out($func_id = 0) { if (!empty(self::$_reward)) { foreach (self::$_reward as $player_id => $reward) { $out = array('type' => 1, 'reward' => array()); foreach ($reward as $r) { if (isset($r['overlay_num']) && $r['overlay_num'] > 0) { $r['item_num'] = $r['overlay_num']; } $out['reward'][] = Struct_Prop::get_prop_struct($r); } $out['func_id'] = $func_id; Protocol::input($player_id, 8, 7, 843, $out); } self::$_reward = null; } }
/** * 上报统计数据 * * @param string $module * @param string $interface * @param bool $success * @param int $code * @param string $msg * @param string $report_address * @return boolean */ public static function report($module, $interface, $success, $code, $msg, $report_address = '') { $report_address = $report_address ? $report_address : 'udp://127.0.0.1:55656'; if (isset(self::$timeMap[$module][$interface]) && self::$timeMap[$module][$interface] > 0) { $time_start = self::$timeMap[$module][$interface]; self::$timeMap[$module][$interface] = 0; } else { if (isset(self::$timeMap['']['']) && self::$timeMap[''][''] > 0) { $time_start = self::$timeMap['']['']; self::$timeMap[''][''] = 0; } else { $time_start = microtime(true); } } $cost_time = microtime(true) - $time_start; $bin_data = Protocol::encode($module, $interface, $cost_time, $success, $code, $msg); return self::sendData($report_address, $bin_data); }
function __construct() { parent::__construct(); $this->_cpid = ''; $this->id = ''; $this->name = ''; $this->language = ''; $this->fname = ''; $this->url = ''; $this->largepreurl = ''; $this->previewurl = ''; $this->purl = ''; $this->size = 0; $this->md5 = ''; $this->folder = ''; $this->type = 0; $this->download_times = 0; }
public function start_task($player_id) { $player_info = $this->get_data('Player')->get_player_info($player_id, array('level')); $level = $player_info['level']; $task_id = $this->get_game('TaskChain')->get_random_chain_task_id($level, 0); echo "player_id;{$player_id} task_id:{$task_id}\n"; $data = array(); if (!empty($task_id)) { $arr_player_task = $this->get_game('TaskChain')->get_init_chain_val($player_id, $task_id, 1); $result = $this->get_data('PlayerTask')->set_task_info($player_id, array('chain_val' => $arr_player_task['chain_val'], 'target_val' => $arr_player_task['target_val'])); if ($result) { $data = $this->get_game('TaskChain')->get_chain_task_list($player_id, $arr_player_task, null, 1, 1); Protocol::input($player_id, 8, 10, 1025, $data); Protocol::out(); return true; } } return false; }