mirror of
https://github.com/wisplite/tether.git
synced 2026-05-01 06:22:41 -05:00
update to use newer client (this is still very broken)
This commit is contained in:
@@ -0,0 +1 @@
|
|||||||
|
node_modules
|
||||||
@@ -0,0 +1,8 @@
|
|||||||
|
import { TetherClient } from "tether-ts";
|
||||||
|
|
||||||
|
const client = new TetherClient();
|
||||||
|
client.connect("ws://localhost:8080/tether");
|
||||||
|
|
||||||
|
client.subscribe("messages", (message) => {
|
||||||
|
console.log("Received message", message);
|
||||||
|
});
|
||||||
Generated
+21
@@ -0,0 +1,21 @@
|
|||||||
|
{
|
||||||
|
"name": "tether-example",
|
||||||
|
"version": "1.0.0",
|
||||||
|
"lockfileVersion": 3,
|
||||||
|
"requires": true,
|
||||||
|
"packages": {
|
||||||
|
"": {
|
||||||
|
"name": "tether-example",
|
||||||
|
"version": "1.0.0",
|
||||||
|
"license": "ISC",
|
||||||
|
"dependencies": {
|
||||||
|
"tether-ts": "github:wisplite/tether-ts"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"node_modules/tether-ts": {
|
||||||
|
"version": "1.0.3",
|
||||||
|
"resolved": "git+ssh://git@github.com/wisplite/tether-ts.git#00eeff128298d5d79d76c22ba609f83c09f5817f",
|
||||||
|
"license": "ISC"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,15 @@
|
|||||||
|
{
|
||||||
|
"name": "tether-example",
|
||||||
|
"version": "1.0.0",
|
||||||
|
"description": "",
|
||||||
|
"license": "ISC",
|
||||||
|
"author": "",
|
||||||
|
"type": "module",
|
||||||
|
"main": "index.ts",
|
||||||
|
"scripts": {
|
||||||
|
"test": "echo \"Error: no test specified\" && exit 1"
|
||||||
|
},
|
||||||
|
"dependencies": {
|
||||||
|
"tether-ts": "github:wisplite/tether-ts"
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,23 +0,0 @@
|
|||||||
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();
|
|
||||||
Reference in New Issue
Block a user