You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

41 lines
1006 B
HTML

<!DOCTYPE html>
<html>
<head><title>WebSocket example</title></head>
<body>
<script type="text/javascript">
function testJSON() {
var jsonSocket = new WebSocket("ws://127.0.0.1:7379/.json");
jsonSocket.onopen = function() {
console.log("JSON socket connected!");
jsonSocket.send(JSON.stringify(["SET", "hello", "world"]));
jsonSocket.send(JSON.stringify(["GET", "hello"]));
};
jsonSocket.onmessage = function(messageEvent) {
console.log("JSON received:", messageEvent.data);
};
}
function testRAW() {
var rawSocket = new WebSocket("ws://127.0.0.1:7379/.raw");
rawSocket.onopen = function() {
console.log("raw socket connected!");
rawSocket.send("*3\r\n$3\r\nSET\r\n$5\r\nhello\r\n$5\r\nworld\r\n");
rawSocket.send("*2\r\n$3\r\nGET\r\n$5\r\nhello\r\n");
};
rawSocket.onmessage = function(messageEvent) {
console.log("Raw received:", messageEvent.data);
};
}
addEventListener("DOMContentLoaded", function(){
testJSON();
testRAW();
}, null);
</script>
</body>
</html>