-
-
Save snailsmall612/8b1997c3a9b3458e79511385c6aafcd2 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!doctype html> | |
<html> | |
<head> | |
<meta charset="UTF-8"> | |
<title>WebSocket test</title> | |
<script> | |
var ws = new WebSocket("ws://localhost:9502"); | |
ws.onopen = function(event) { | |
console.log("客户端已連接上!"); | |
ws.send("hello server, this is client!"); //client to server message | |
}; | |
ws.onmessage = function(event) { | |
console.log("server message: " + event.data); | |
} | |
ws.onclose = function(event) { | |
console.log("連接已關閉"); | |
}; | |
</script> | |
</head> | |
<body> | |
WebSocket test | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment