@@ -34,7 +34,15 @@ class ChatController extends BaseController
//发消息 shish 2019.12.28
public function actionSend()
{
- Gateway::sendToUid($uid, $dat);
+ $post = Yii::$app->request->post();
+ $msg = isset($post['msg']) ? $post['msg'] : '';
+
+ $m = json_encode(array(
+ 'type' => 'msg',
+ 'msg' => $msg,
+ ));
+ Gateway::sendToUid($uid, $m);
}
@@ -1,3 +1,4 @@
+<butto onclick="get()">请求</butto>
<script src="http://libs.baidu.com/jquery/2.0.0/jquery.min.js"></script>
<script>
ws = new WebSocket("ws://127.0.0.1:8282");
@@ -11,7 +12,13 @@
$.post('http://api.m.huaml.com/chat/bind', {clientId: data.client_id}, function(data){}, 'json');
break;
default :
- alert(e.data);
+ console.log(e.data);
};
+ function get()
+ {
+ $.post('http://api.m.huaml.com/chat/send', {msg: '您好'}, function(data){}, 'json');
+ }
</script>