WsController.php 905 B

12345678910111213141516171819202122232425262728293031323334353637
  1. <?php
  2. // websocket相关
  3. namespace ghs\controllers;
  4. use bizGhs\ws\services\WsService;
  5. use common\components\util;
  6. use Yii;
  7. use GatewayClient\Gateway;
  8. class WsController extends BaseController
  9. {
  10. //绑定用户
  11. public function actionBind()
  12. {
  13. $post = Yii::$app->request->post();
  14. $clientId = isset($post['clientId']) ? $post['clientId'] : '';
  15. $shopAdminId = $this->shopAdminId;
  16. Gateway::bindUid($clientId, $shopAdminId);
  17. util::complete();
  18. }
  19. //关闭当前链接
  20. public function actionClose()
  21. {
  22. $post = Yii::$app->request->post();
  23. $clientId = isset($post['clientId']) ? $post['clientId'] : '';
  24. Gateway::closeClient($clientId);
  25. }
  26. //模拟推送ws (仅供测试联调用)
  27. public function actionSend()
  28. {
  29. WsService::arrivalNotice($this->shopAdminId,9866.29);
  30. util::complete();
  31. }
  32. }