mirror of
https://github.com/wisplite/tether.git
synced 2026-05-01 06:22:41 -05:00
basic websocket handling and testing
This commit is contained in:
@@ -0,0 +1,17 @@
|
||||
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",
|
||||
}));
|
||||
};
|
||||
ws.onclose = () => {
|
||||
console.log("Disconnected from server");
|
||||
};
|
||||
}
|
||||
test();
|
||||
Reference in New Issue
Block a user