Skip to content

Instantly share code, notes, and snippets.

@monodyle
Created September 10, 2021 16:18
Show Gist options
  • Save monodyle/c583a2711ba03899cae7670cbb23a56a to your computer and use it in GitHub Desktop.
Save monodyle/c583a2711ba03899cae7670cbb23a56a to your computer and use it in GitHub Desktop.
tokyo.ts
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