<script type="text/javascript">
var ws = new WebSocket("ws://38.55.97.143:6162/");
ws.onopen = function(event) {
console.log("WebSocket connection opened");
// 可以在这里发送数据给服务器
ws.send("Hello, server!");
};
ws.onmessage = function(event) {
console.log("Received message from server: " + event.data);
};
ws.onclose = function(event) {
console.log("WebSocket connection closed");
};
ws.onerror = function(error) {
console.error("WebSocket error observed:", error);
};
</script>
发表评论 取消回复