13 lines
506 B
HTML
13 lines
506 B
HTML
<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> |