国产+高潮+在线,国产 av 仑乱内谢,www国产亚洲精品久久,51国产偷自视频区视频,成人午夜精品网站在线观看

Gateway::updateSession session添加丟失 獲取不到

luciferid
<?php 
/**
 * This file is part of workerman.
 *
 * Licensed under The MIT License
 * For full copyright and license information, please see the MIT-LICENSE.txt
 * Redistributions of files must retain the above copyright notice.
 *
 * @author walkor<walkor@workerman.net>
 * @copyright walkor<walkor@workerman.net>
 * @link http://m.wtbis.cn/
 * @license http://www.opensource.org/licenses/mit-license.php MIT License
 */
use \Workerman\Worker;
use \Workerman\Autoloader;
use Workerman\Lib\Timer;
use Channel\Client;
use GatewayWorker\Lib\Gateway;
use Shared\Config\nswc_timer;
use Shared\Model\Game\NSWC_Model;
use GlobalData\GClient;
use Shared\Config\nswc;

 // (我一共起了 四個進程處理,發(fā)現(xiàn)當客戶端1和客戶端2 都連接到相同的進程號的時候,出現(xiàn)后邊登錄客戶端 //session  沒有跟新成功 )

// 自動加載類
require_once __DIR__ . '/../../Workerman/Autoloader.php';
Autoloader::setRootPath(__DIR__);

$task = new Worker();
// 開啟多少個進程運行定時任務,注意多進程并發(fā)問題
$task->count = 4;
$task->onWorkerStart = function($task)
{
    global $global;//定義business中 共享數(shù)據(jù)單例對象
    $global = new GClient('127.0.0.1:2207');

    Channel\Client::connect('127.0.0.1', 2206);

    $name = $task->id .'_' . nswc_timer::leave_nswc;
    //添加一個離開房間的定時器
    Channel\Client::on($name, function($data){

        NSWC_Model::test('添加一個離開房間的定時器');

        $timer_id = Timer::add('12', function ()use(&$timer_id,$data){
            NSWC_Model::test('離開定時器觸發(fā)');

           NSWC_Model::GetInstance()->leave_nswc($data,$data,$data);

        },array(),false);

        $session = array('timer_leave_nswc'=>$timer_id);

        Gateway::updateSession($data , $session);
    });

};

// 如果不是在根目錄啟動,則運行runAll方法
if(!defined('GLOBAL_START'))
{
    Worker::runAll();
}
4982 2 0
2個回答

walkor 打賞

這個屬于在GatewayWorker外部調用Gateway接口,類似使用GatewayClient,要在onWorkerStart里面設置下 Gateway::$registerAddress = 'register服務ip:register端口';

  • luciferid 2016-11-08

    @1 使用了你提供的方法在onWorkerStart 中 還是丟失 我感覺是Gateway::updateSession 的問題

  • luciferid 2016-11-08

    我找到解決方案了, walkor
    session確實丟失了,
    解決方法就是,要在business 業(yè)務邏輯中 保存下session : gateway::updateSession($client_id, $_SESSION);

    這樣在其他的外部進程中獲取到的就是全部的session信息,要不然會丟失

  • walkor 2016-11-08

    怎么保存的帖下吧。
    另外帖的代碼都是Worker的代碼,并不是businessWorker。
    從你的代碼中并沒有看出來哪里用了GatewayWorker。
    而且我也不清楚你有哪些進程,進程間關系,業(yè)務邏輯也沒有,比如哪里讀的session

luciferid
<?php 
/**
 * This file is part of workerman.
 *
 * Licensed under The MIT License
 * For full copyright and license information, please see the MIT-LICENSE.txt
 * Redistributions of files must retain the above copyright notice.
 *
 * @author walkor<walkor@workerman.net>
 * @copyright walkor<walkor@workerman.net>
 * @link http://m.wtbis.cn/
 * @license http://www.opensource.org/licenses/mit-license.php MIT License
 */
use \Workerman\Worker;
use \Workerman\Autoloader;
use Workerman\Lib\Timer;
use Channel\Client;
use GatewayWorker\Lib\Gateway;
use Shared\Config\nswc_timer;
use Shared\Model\Game\NSWC_Model;
use GlobalData\GClient;
use Shared\Config\nswc;

// (我一共起了 四個進程處理,發(fā)現(xiàn)當客戶端1和客戶端2 都連接到相同的進程號的時候,出現(xiàn)后邊登錄客戶端 //session 沒有跟新成功 )

// 自動加載類
require_once __DIR__ . '/../../Workerman/Autoloader.php';
Autoloader::setRootPath(__DIR__);

$task = new Worker();
// 開啟多少個進程運行定時任務,注意多進程并發(fā)問題
$task->count = 4;
$task->onWorkerStart = function($task)
{

    Gateway::$registerAddress = '127.0.0.1:1236';

    global $global;//定義business中 共享數(shù)據(jù)單例對象
    $global = new GClient('127.0.0.1:2207');

    Channel\Client::connect('127.0.0.1', 2206);

    $name = $task->id .'_' . nswc_timer::leave_nswc;
//添加一個離開房間的定時器
    Channel\Client::on($name, function($data){

        NSWC_Model::test('添加一個離開房間的定時器');

        $timer_id = Timer::add('12', function ()use(&$timer_id,$data){
            NSWC_Model::test('離開定時器觸發(fā)');

            NSWC_Model::GetInstance()->leave_nswc($data,$data,$data);

        },array(),false);

        $session = array('timer_leave_nswc'=>$timer_id);

        Gateway::updateSession($data , $session);
    });

};

// 如果不是在根目錄啟動,則運行runAll方法
if(!defined('GLOBAL_START'))
{
    Worker::runAll();
}
  • luciferid 2016-11-08

    依然無法解決.............照樣丟失.................問題就在這Gateway::updateSession 方法

  • walkor 2016-11-08

    打下日志吧,看看updateSession的client_id和獲取的是不是一個。

年代過于久遠,無法發(fā)表回答
??