ChatController.php 755 B

12345678910111213141516171819202122232425262728293031323334353637383940
  1. <?php
  2. namespace client\controllers;
  3. use Yii;
  4. use yii\web\Controller;
  5. use common\components\util;
  6. use GatewayClient\Gateway;
  7. class ChatController extends BaseController
  8. {
  9. public function beforeAction($action)
  10. {
  11. return parent::beforeAction($action);
  12. }
  13. //聊天首页,前端使用
  14. public function actionIndex()
  15. {
  16. return $this->renderPartial('index');
  17. }
  18. //绑定 shish 2019.12.28
  19. public function actionBind()
  20. {
  21. $post = Yii::$app->request->post();
  22. $clientId = isset($post['clientId']) ? $post['clientId'] : '';
  23. $userId = $this->userId;
  24. Gateway::$registerAddress = '127.0.0.1:1238';
  25. Gateway::bindUid($clientId, $userId);
  26. }
  27. //发消息 shish 2019.12.28
  28. public function actionSend()
  29. {
  30. Gateway::sendToUid($uid, $dat);
  31. }
  32. }