Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

請問這範例中的$_SESSION是php本身的session嗎? #5

Closed
esliupm opened this issue Jul 12, 2017 · 3 comments
Closed

請問這範例中的$_SESSION是php本身的session嗎? #5

esliupm opened this issue Jul 12, 2017 · 3 comments

Comments

@esliupm
Copy link

esliupm commented Jul 12, 2017

$item) { $clients_list[$tmp_client_id] = $item['client_name']; } 但是$item['client_name'] 會是 null,這是什麼原因呢??
@walkor
Copy link
Owner

walkor commented Jul 13, 2017

抱歉,看不到你的说的范例是什么。
代码看起来样式有问题,请使用github的编辑器把代码整理好。
感谢

@esliupm
Copy link
Author

esliupm commented Jul 13, 2017

//bind.php
//加载GatewayClient。安装GatewayClient参见本页面底部介绍
require_once '/your/path/GatewayClient/Gateway.php';
// GatewayClient 3.0.0版本开始要使用命名空间
use GatewayClient\Gateway;
// 设置GatewayWorker服务的Register服务ip和端口,请根据实际情况改成实际值
Gateway::$registerAddress = '127.0.0.1:1236';

// 假设用户已经登录,用户uid和群组id在session中
$uid = $_SESSION['uid'];
$group_id = $_SESSION['group'];
// client_id与uid绑定
Gateway::bindUid($client_id, $uid);
// 加入某个群组(可调用多次加入多个群组)
Gateway::joinGroup($client_id, $group_id);

=================================
問題2
bind.php 內我加上
$clients_list = Gateway::getClientSessionsByGroup($_POST["room_id"]);
foreach($clients_list as $tmp_client_id=>$item)
{
$clients_list[$tmp_client_id] = $item['client_name'];
}
但是$item['client_name'] 會是 null,這是什麼原因呢??

@walkor
Copy link
Owner

walkor commented Jul 13, 2017

例子中的$_SESSION是php的session,但是Gateway的session不是php自带的session。

Gateway的session需要用Gateway::setSessions Gateway::setSession给client_id设置session

@walkor walkor closed this as completed May 24, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants