| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748 |
- <?php
- namespace client\controllers;
- use Yii;
- use yii\web\Controller;
- use common\components\util;
- use GatewayClient\Gateway;
- class ChatController extends BaseController
- {
- public function beforeAction($action)
- {
- return parent::beforeAction($action);
- }
- //聊天首页,前端使用
- public function actionIndex()
- {
- return $this->renderPartial('index');
- }
-
- //绑定 shish 2019.12.28
- public function actionBind()
- {
- $post = Yii::$app->request->post();
- $clientId = isset($post['clientId']) ? $post['clientId'] : '';
- $userId = $this->userId;
- Gateway::$registerAddress = '127.0.0.1:1238';
- Gateway::bindUid($clientId, $userId);
- }
- //发消息 shish 2019.12.28
- public function actionSend()
- {
- $post = Yii::$app->request->post();
- $msg = isset($post['msg']) ? $post['msg'] : '';
-
- $m = json_encode(array(
- 'type' => 'msg',
- 'msg' => $msg,
- ));
-
- Gateway::sendToUid($uid, $m);
- }
-
- }
|