Created
September 10, 2021 16:18
-
-
Save monodyle/c583a2711ba03899cae7670cbb23a56a to your computer and use it in GitHub Desktop.
tokyo.ts
This file contains hidden or 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
const id = (Math.random() + 1).toString(36).substring(4); | |
const endpoint = `ws://tokyo.thuc.space/socket?key=${id}&name=${id}`; | |
const ws = new WebSocket(endpoint); | |
const rotate = (deg: number) => ws.send(`{"e": "rotate", "data": ${deg}}`); | |
const fire = () => ws.send(`{"e": "fire"}`); | |
ws.onopen = () => { | |
console.log("connected!"); | |
// ws.onmessage = (message) => {}; | |
const interval = setInterval(() => { | |
rotate(Math.random() * 360); | |
fire(); | |
}, 100); | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment