WsController.php 983 B

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