WsController.php 626 B

123456789101112131415161718192021222324252627
  1. <?php
  2. // websocket相关
  3. namespace ghs\controllers;
  4. use Yii;
  5. use GatewayClient\Gateway;
  6. class WsController extends BaseController
  7. {
  8. //绑定用户
  9. public function actionBind()
  10. {
  11. $post = Yii::$app->request->post();
  12. $clientId = isset($post['clientId']) ? $post['clientId'] : '';
  13. $adminId = $this->adminId;
  14. Gateway::bindUid($clientId, $adminId);
  15. }
  16. //关闭当前链接
  17. public function actionClose()
  18. {
  19. $post = Yii::$app->request->post();
  20. $clientId = isset($post['clientId']) ? $post['clientId'] : '';
  21. Gateway::closeClient($clientId);
  22. }
  23. }