| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849 |
- <?php
- /**
- * User: admin
- * Date Time: 2021/5/8 20:26
- */
- namespace hd\controllers;
- use bizGhs\ws\services\WsService;
- use common\components\util;
- use Yii;
- use GatewayClient\Gateway;
- class WsController extends BaseController
- {
- public $guestAccess = ['bind','send'];
- //绑定用户
- public function actionBind()
- {
- $post = Yii::$app->request->post();
- $clientId = isset($post['clientId']) ? $post['clientId'] : '';
- $shopAdminId = $this->shopAdminId;
- $res = Gateway::bindUid($clientId, $shopAdminId);
- Yii::info("ws band shopAdminId clientId res: ". $shopAdminId.'---'.$clientId.$res);
- $isOnlineUid = Gateway::isUidOnline($shopAdminId);
- $isOnline = Gateway::isOnline($clientId);
- // Yii::$app->cache->set($shopAdminId,$clientId);
- Yii::info("ws band isOnlineUid isOnline ". $isOnlineUid.'---'.$isOnline);
- util::complete();
- }
- //关闭当前链接
- public function actionClose()
- {
- $post = Yii::$app->request->post();
- $clientId = isset($post['clientId']) ? $post['clientId'] : '';
- Gateway::closeClient($clientId);
- }
- //模拟推送ws (仅供测试联调用)
- public function actionSend()
- {
- WsService::arrivalNotice($this->shopAdminId, 9866.29);
- util::complete();
- }
- }
|