| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152 |
- <?php
- namespace business\controllers;
- use common\components\stringUtil;
- use common\components\util;
- use Yii;
- use GatewayClient\Gateway;
- class MainController extends BaseController
- {
-
- public function actionDemo()
- {
- return $this->renderPartial('demo');
- }
- public function actionBind()
- {
- //加载GatewayClient。安装GatewayClient参见本页面底部介绍
- require_once '/your/path/GatewayClient/Gateway.php';
- // GatewayClient 3.0.0版本开始要使用命名空间
-
-
- // 设置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);
- }
- public function actionSend()
- {
- //加载GatewayClient。安装GatewayClient参见本页面底部介绍
- require_once '/your/path/GatewayClient/Gateway.php';
- // GatewayClient 3.0.0版本开始要使用命名空间
-
- // 设置GatewayWorker服务的Register服务ip和端口,请根据实际情况改成实际值
- Gateway::$registerAddress = '127.0.0.1:1236';
-
- // 向任意uid的网站页面发送数据
- Gateway::sendToUid($uid, $message);
- // 向任意群组的网站页面发送数据
- Gateway::sendToGroup($group, $message);
- }
-
- }
|