Skip to content

Commit

Permalink
Remove debugging crap
Browse files Browse the repository at this point in the history
  • Loading branch information
Alhadis committed Feb 4, 2020
1 parent 6a9e229 commit e1b0b25
Showing 1 changed file with 1 addition and 23 deletions.
24 changes: 1 addition & 23 deletions bin/ws.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import EventEmitter from "events";
import {fileURLToPath} from "url";
import {
clamp,
escapeCtrl,
utf8Decode,
utf8Encode,
wsDecodeFrame,
Expand All @@ -21,28 +20,7 @@ const path = fileURLToPath(import.meta.url);

const port = +process.argv[2] || 1338;
const server = new Server();
server.listen(port)
.on("ws:message", (ws, msg) => {
msg = Buffer.isBuffer(msg) ? msg.inspect() : msg;
console.log(escapeCtrl(`Client #${ws.id}: ${msg}`));
})
.on("ws:ping", ({id}) => console.log(`Client #${id}: PING`))
.on("ws:pong", ({id}) => console.log(`Client #${id}: PONG`))
.on("ws:open", ws => {
console.log(`Client #${ws.id} connected`);
ws.maxSize = 6;
ws.ping();
ws.send("ABCDEFGHIJKLMNOPQRSTUVWXYZ");
setTimeout(() => server.close(1000, "Done"), 4000);
})
.on("ws:close", ({id}, code, reason) => {
let message = `Client #${id} disconnected`;
if(code){
reason = reason ? ": " + reason : "";
message += ` (${code}${reason})`;
}
console.log(message);
});
server.listen(port);
console.log(`[PID: ${process.pid}] WebSocket server listening on port ${port}`);

})().catch(error => {
Expand Down

0 comments on commit e1b0b25

Please sign in to comment.