本文整理汇总了PHP中Protocol类的典型用法代码示例。如果您正苦于以下问题:PHP Protocol类的具体用法?PHP Protocol怎么用?PHP Protocol使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Protocol类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: testProtocolSuccess
public function testProtocolSuccess()
{
$protocol = new Protocol();
$protocol->modality_id = 1;
$protocol->name = "Rita 3cm Protocol";
$protocol->algorithm = "Some storage pattern";
$this->assertTrue($protocol->save());
}
示例2: getOutput
/**
* 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;
}
示例3: out
/**
* 输出协议
* @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]);
}
}
示例4: router
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;
}
}
}
示例5: route
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();
}
}
示例6: run
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;
}
示例7: run
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;
}
示例8: out
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;
}
}
示例9: sync
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();
}
}
}
示例10: report
/**
* 上报统计数据
*
* @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);
}
}
示例11: prop_806
/**
* 道具变更下行协议
* @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);
}
}
示例12: async_update_union_guide
/**
* @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();
}
}
}
}
示例13: doAction
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;
}
示例14: show
/**
* 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'));
//
}
示例15: doAction
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);
}