Files
xk-api-yii/web/websoct.html

13 lines
506 B
HTML
Raw Normal View History

2024-09-19 11:32:39 +08:00
<script>
/**
* 与GatewayWorker建立websocket连接域名和端口改为你实际的域名端口
* 其中端口为Gateway端口即start_gateway.php指定的端口。
* start_gateway.php 中需要指定websocket协议像这样
* $gateway = new Gateway(websocket://0.0.0.0:7272);
*/
ws = new WebSocket("ws://127.0.0.1:8282");
// 服务端主动推送消息时会触发这里的onmessage
ws.onmessage = function(e){
console.log(e)
};
</script>