fix example

This commit is contained in:
Luca Conte 2024-08-21 19:43:47 +02:00
parent 542dc31578
commit 0a5c0b9a64
2 changed files with 11 additions and 2 deletions

View File

@ -3,6 +3,12 @@
let sock = new SmartWebSocket("ws://127.0.0.1:8082");
sock.on("test", console.log);
sock.on("test", (data) => {
console.log(data);
});
sock.on("open", () => {
sock.send("test2", "mydata");
})
</script>

View File

@ -5,9 +5,12 @@ const wss = new WebSocketServer({ port: 8082 });
upgradeWSS(wss);
wss.on("u_connection", (ws) => {
wss.on("connection", (ws) => {
console.log("connected");
ws.sendEvent("test", { "abc" : 123 });
ws.on("test2", (data) => {
console.log(data);
});
});
wss.on("listening", () => {