Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
  • Loading branch information
abedra committed Feb 13, 2022
1 parent 705b003 commit b1cc291
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 5 deletions.
1 change: 1 addition & 0 deletions example/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
build
17 changes: 12 additions & 5 deletions example/server/index.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,18 @@
const ws = require('ws');

const wss = new ws.WebSocketServer({ port: 8080 });
let count = 0;

const start = ws => {
console.log("Counting down")

for (i = 0; i < 10; i++) {
ws.send(i)
}

console.log("Countdown complete, closing connection")
ws.close()
}

wss.on('connection', function connection(ws) {
setInterval(() => {
ws.send(count)
count += 1
}, 1000);
start(ws)
});

0 comments on commit b1cc291

Please sign in to comment.