Last active
April 7, 2021 08:34
-
-
Save mkozjak/fa9296484c40445af516e563c65536bf 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> | |
<script type="text/javascript" src="./lib/rpcwebsockets.js"></script> | |
<script type="text/javascript"> | |
function myFunction() { | |
var ws = new RPCWebSocket("ws://127.0.0.1:3333") | |
ws.once("open", function() { | |
console.log("socket opened") | |
ws.call("sum", [ 5, 3 ]) | |
.then(function(resp) { | |
alert("server response: " + resp) | |
ws.close() | |
}) | |
}) | |
ws.once("close", function() { | |
console.log("socket closed") | |
}) | |
} | |
</script> | |
</head> | |
<body> | |
<h1>rpc-websockets browser test</h1> | |
<button type="button" onclick="myFunction()">Try it</button> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
there is no rpcwebsockets.js in the lib directory
when I include index.browser-bundle.js and go for new RPCWebSocket it says RPCWebSocket is not a constructor thumb down