Example #1
0
 /**
  * 处理请求
  * @see Man\Core.SocketWorker::dealProcess()
  */
 public function dealProcess($recv_buffer)
 {
     $pack = new GatewayProtocol($recv_buffer);
     Context::$client_ip = $pack->header['client_ip'];
     Context::$client_port = $pack->header['client_port'];
     Context::$local_ip = $pack->header['local_ip'];
     Context::$local_port = $pack->header['local_port'];
     Context::$socket_id = $pack->header['socket_id'];
     Context::$client_id = $pack->header['client_id'];
     $_SERVER = array('REMOTE_ADDR' => Context::$client_ip, 'REMOTE_PORT' => Context::$client_port, 'GATEWAY_ADDR' => Context::$local_ip, 'GATEWAY_PORT' => Context::$local_port, 'GATEWAY_CLIENT_ID' => Context::$client_id);
     if ($pack->ext_data != '') {
         $_SESSION = Context::sessionDecode($pack->ext_data);
     } else {
         $_SESSION = null;
     }
     // 备份一次$pack->ext_data,请求处理完毕后判断session是否和备份相等,不相等就更新session
     $session_str_copy = $pack->ext_data;
     $cmd = $pack->header['cmd'];
     $interface = isset(self::$interfaceMap[$cmd]) ? self::$interfaceMap[$cmd] : $cmd;
     StatisticClient::tick(__CLASS__, $interface);
     try {
         switch ($cmd) {
             case GatewayProtocol::CMD_ON_GATEWAY_CONNECTION:
                 Event::onGatewayConnect(Context::$client_id);
                 break;
             case GatewayProtocol::CMD_ON_MESSAGE:
                 Event::onMessage(Context::$client_id, $pack->body);
                 break;
             case GatewayProtocol::CMD_ON_CLOSE:
                 Event::onClose(Context::$client_id);
                 break;
         }
         StatisticClient::report(__CLASS__, $interface, 1, 0, '');
     } catch (\Exception $e) {
         $msg = 'client_id:' . Context::$client_id . "\tclient_ip:" . Context::$client_ip . "\n" . $e->__toString();
         StatisticClient::report(__CLASS__, $interface, 0, $e->getCode() > 0 ? $e->getCode() : 201, $msg);
     }
     $session_str_now = $_SESSION !== null ? Context::sessionEncode($_SESSION) : '';
     if ($session_str_copy != $session_str_now) {
         Gateway::updateSocketSession(Context::$socket_id, $session_str_now);
     }
     Context::clear();
 }
Example #2
0
<?php

require_once __DIR__ . "/../libs/Event.php";
require_once __DIR__ . "/../libs/Error.php";
require_once __DIR__ . "/../db/Db.php";
header('Expires: Mon, 26 Jul 1997 05:00:00 GMT');
header('Last-Modified: ' . gmdate('D, d M Y H:i:s') . 'GMT');
header('Cache-Control: no-cache, must-revalidate');
header('Pragma: no-cache');
if (!isset($_GET["u"])) {
    exit(Error::getRetString(1));
}
$json_string = file_get_contents("php://input");
// $json_string = $GLOBALS['HTTP_RAW_POST_DATA'];
$array = json_decode($json_string, true);
echo Event::onMessage($array, __DIR__ . "/../base/");
// file_put_contents("./test.txt", $_GET["u"]."\n".$json_string, FILE_APPEND);
Example #3
0
<?php

require_once __DIR__ . "/../libs/iBeeAir2/core/Event.php";
require_once __DIR__ . "/../libs/Db.php";
header('Expires: Mon, 26 Jul 1997 05:00:00 GMT');
header('Last-Modified: ' . gmdate('D, d M Y H:i:s') . 'GMT');
header('Cache-Control: no-cache, must-revalidate');
header('Pragma: no-cache');
//var_dump($_GET);
if (!isset($_GET["uuid"])) {
}
$json_string = file_get_contents("php://input");
$array = json_decode($json_string, true);
//解析post数据
//执行系统事件
echo Event::onMessage($array, __DIR__ . "/../libs/iBeeAir2/manage/");
Example #4
0
<?php

require_once __DIR__ . "/../libs/Event.php";
require_once __DIR__ . "/../db/Db.php";
header('Expires: Mon, 26 Jul 1997 05:00:00 GMT');
header('Last-Modified: ' . gmdate('D, d M Y H:i:s') . 'GMT');
header('Cache-Control: no-cache, must-revalidate');
header('Pragma: no-cache');
//var_dump($_GET);
if (!isset($_GET["uuid"])) {
}
$json_string = file_get_contents("php://input");
//$json_string = $GLOBALS['HTTP_RAW_POST_DATA'];
$array = json_decode($json_string, true);
//解析post数据
//执行系统事件
echo Event::onMessage($array, __DIR__ . "/../user/");
Example #5
0
<?php

require_once __DIR__ . "/libs/Event.php";
require_once __DIR__ . "/libs/functions.php";
header('Expires: Mon, 26 Jul 1997 05:00:00 GMT');
header('Last-Modified: ' . gmdate('D, d M Y H:i:s') . 'GMT');
header('Cache-Control: no-cache, must-revalidate');
header('Pragma: no-cache');
if (isset($_GET["u"])) {
    if (verify_user($_GET["u"]) == true) {
        $json_string = file_get_contents("php://input");
        Event::onMessage(json_decode($json_string, true), __DIR__ . "/libs/Services");
    } else {
        echo '{"code":33406, "msg":"invalid tdid or u"}';
    }
} else {
    echo '{"code":33407, "msg":"miss param tdid or u"}';
}
Example #6
0
<?php

require_once _DIR_ . "/libs/Event.php";
require_once _DIR_ . "/libs/Error.php";
// require_once (_DIR_."");
header('Expires: Mon, 26 Jul 1997 05:00:00 GMT');
header('Last-Modified: ' . gmdate('D, d M Y H:i:s') . 'GMT');
header('Cache-Control: no-cache, must-revalidate');
header('Pragma: no-cache');
if (!isset($_GET["u"])) {
    exit(Error::getRetString(1));
}
$json_string = file_get_contents("php://input");
$array = json_decode($json_string, true);
echo Event::onMessage($array, __DIR__ . "/manage//");
file_put_contents("./test.txt", $_GET["u"] . "\n" . $json_string, FILE_APPEND);