WsController.php 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  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\goWs;
  9. use common\components\util;
  10. use Yii;
  11. use GatewayClient\Gateway;
  12. class WsController extends BaseController
  13. {
  14. public $guestAccess = ['bind','send'];
  15. //绑定用户
  16. public function actionBind()
  17. {
  18. $post = Yii::$app->request->post();
  19. $clientId = isset($post['clientId']) ? $post['clientId'] : '';
  20. $eId = $this->shopAdminId;
  21. // Gateway::bindUid($clientId, $eId);
  22. goWs::bindUid($eId,$clientId);
  23. util::complete();
  24. }
  25. //关闭当前链接
  26. public function actionClose()
  27. {
  28. $post = Yii::$app->request->post();
  29. $clientId = isset($post['clientId']) ? $post['clientId'] : '';
  30. Gateway::closeClient($clientId);
  31. }
  32. //模拟推送ws (仅供测试联调用)
  33. public function actionSend()
  34. {
  35. WsService::arrivalNotice($this->shopAdminId, 9866.29,1);
  36. util::complete();
  37. }
  38. //模拟推送订单通知
  39. public function actionSendOrder()
  40. {
  41. WsService::newOrderNotice($this->shopAdminId);
  42. util::complete();
  43. }
  44. }