shish 6 vuotta sitten
vanhempi
commit
9581e7f09c
2 muutettua tiedostoa jossa 17 lisäystä ja 2 poistoa
  1. 9 1
      app/client/controllers/ChatController.php
  2. 8 1
      app/client/views/chat/index.php

+ 9 - 1
app/client/controllers/ChatController.php

@@ -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);
 	}
 	
 }

+ 8 - 1
app/client/views/chat/index.php

@@ -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>