WsController.php 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. <?php
  2. // websocket相关
  3. namespace ghs\controllers;
  4. use bizGhs\ws\services\WsService;
  5. use common\components\goWs;
  6. use common\components\util;
  7. use Yii;
  8. use GatewayClient\Gateway;
  9. class WsController extends BaseController
  10. {
  11. public $guestAccess = ['bind','send'];
  12. //绑定用户
  13. public function actionBind()
  14. {
  15. $post = Yii::$app->request->post();
  16. $clientId = isset($post['clientId']) ? $post['clientId'] : '';
  17. $shopAdminId = $this->shopAdminId;
  18. // Yii::info("ws band shopAdminId clientId ". $shopAdminId.'---'.$clientId);
  19. //Gateway::bindUid($clientId, $shopAdminId);
  20. goWs::bindUid($shopAdminId,$clientId);
  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. }
  31. //模拟推送ws (仅供测试联调用)
  32. public function actionSend()
  33. {
  34. WsService::arrivalNotice($this->shopAdminId, 9866.29,1);
  35. util::complete();
  36. }
  37. //模拟推送订单通知
  38. public function actionSendOrder()
  39. {
  40. WsService::newOrderNotice($this->shopAdminId);
  41. util::complete();
  42. }
  43. }