Files
xk-api-yii/web/websoct.html
2024-09-19 11:32:39 +08:00

13 lines
506 B
HTML
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
<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>