Skip to content

Instantly share code, notes, and snippets.

@kaineer
Last active December 24, 2024 06:52
Show Gist options
  • Save kaineer/a531b1b2ffd4e86c2c46452f596a34f6 to your computer and use it in GitHub Desktop.
Save kaineer/a531b1b2ffd4e86c2c46452f596a34f6 to your computer and use it in GitHub Desktop.
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title></title>
</head>
<body>
<form action="">
<input type="text" name="token">
<button>Connect</button>
</form>
<script>
const host = "10.1.0.213:8080";
const node = "62e060b2-cc85-43a0-a34c-e5adb231b8c9";
const input = document.querySelector("input");
document.querySelector("button").addEventListener("click", (e) => {
e.preventDefault();
const url = "ws://" + host + "/game-engine/web-socket/node?root-id=" + node + "&token=" + input.value;
const ws = new WebSocket(url);
ws.onopen = () => {
console.log("Socket open");
}
ws.onmessage = (message) => {
console.log("Socket got message");
console.log({message});
}
ws.onclose = () => {
console.log("Socket closed");
}
});
</script>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment