| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051 |
- <?php
- // websocket相关
- namespace ghs\controllers;
- use bizGhs\ws\services\WsService;
- use common\components\goWs;
- 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;
- // Yii::info("ws band shopAdminId clientId ". $shopAdminId.'---'.$clientId);
- //Gateway::bindUid($clientId, $shopAdminId);
- goWs::bindUid($shopAdminId,$clientId);
- 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,1);
- util::complete();
- }
- //模拟推送订单通知
- public function actionSendOrder()
- {
- WsService::newOrderNotice($this->shopAdminId);
- util::complete();
- }
- }
|