|
|
@@ -2,8 +2,6 @@
|
|
|
|
|
|
namespace business\controllers;
|
|
|
|
|
|
-use common\components\stringUtil;
|
|
|
-use common\components\util;
|
|
|
use Yii;
|
|
|
use GatewayClient\Gateway;
|
|
|
|
|
|
@@ -14,39 +12,47 @@ class MainController extends BaseController
|
|
|
{
|
|
|
return $this->renderPartial('demo');
|
|
|
}
|
|
|
-
|
|
|
- public function actionBind()
|
|
|
+
|
|
|
+
|
|
|
+ public function actionIndex()
|
|
|
{
|
|
|
- //加载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);
|
|
|
+ return $this->renderPartial('index');
|
|
|
}
|
|
|
-
|
|
|
- public function actionSend()
|
|
|
+
|
|
|
+ //新客户 shish 2019.12.29
|
|
|
+ public function actionVisit()
|
|
|
{
|
|
|
- //加载GatewayClient。安装GatewayClient参见本页面底部介绍
|
|
|
- require_once '/your/path/GatewayClient/Gateway.php';
|
|
|
- // GatewayClient 3.0.0版本开始要使用命名空间
|
|
|
+ $data = json_encode(array(
|
|
|
+ 'type' => 'msg',
|
|
|
+ 'msg' => 'aaaa',
|
|
|
+ ));
|
|
|
|
|
|
- // 设置GatewayWorker服务的Register服务ip和端口,请根据实际情况改成实际值
|
|
|
- Gateway::$registerAddress = '127.0.0.1:1236';
|
|
|
+ $id = 'merchantConsole_' . $this->merchantId;
|
|
|
+ $online = Gateway::getClientIdByUid($id);
|
|
|
+ if ($online) {
|
|
|
+ //直接发送
|
|
|
+ Gateway::sendToUid($id, json_encode($data));
|
|
|
+ } else {
|
|
|
+ //保存
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ //新订单 shish 2019.12.29
|
|
|
+ public function actionOrder()
|
|
|
+ {
|
|
|
+ $data = json_encode(array(
|
|
|
+ 'type' => 'msg',
|
|
|
+ 'msg' => 'aaaa',
|
|
|
+ ));
|
|
|
|
|
|
- // 向任意uid的网站页面发送数据
|
|
|
- Gateway::sendToUid($uid, $message);
|
|
|
- // 向任意群组的网站页面发送数据
|
|
|
- Gateway::sendToGroup($group, $message);
|
|
|
+ $id = 'merchantConsole_' . $this->merchantId;
|
|
|
+ $online = Gateway::getClientIdByUid($id);
|
|
|
+ if ($online) {
|
|
|
+ //直接发送
|
|
|
+ Gateway::sendToUid($id, json_encode($data));
|
|
|
+ } else {
|
|
|
+ //保存
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
}
|