mirror of
https://github.com/wisplite/tether.git
synced 2026-05-01 06:22:41 -05:00
23 lines
505 B
TypeScript
23 lines
505 B
TypeScript
function test() {
|
|
const ws = new WebSocket("ws://localhost:8080/tether");
|
|
ws.onmessage = (event) => {
|
|
console.log(event.data);
|
|
};
|
|
ws.onopen = () => {
|
|
console.log("Connected to server");
|
|
ws.send(JSON.stringify({
|
|
type: "subscribe",
|
|
channel: "messages",
|
|
}));
|
|
setTimeout(() => {
|
|
ws.send(JSON.stringify({
|
|
type: "unsubscribe",
|
|
channel: "messages",
|
|
}));
|
|
}, 5000);
|
|
};
|
|
ws.onclose = () => {
|
|
console.log("Disconnected from server");
|
|
};
|
|
}
|
|
test(); |