wsrelay
v1.0.0
Published
Websocket server that handles multiple client connections and relays each message received to every other client.
Readme
Basic WebSockets Relay Server
Multiple clients can connect to this WebSockets server. Whenever a message is sent to the server by a client, every other client gets the message. Relay.
Install
npm install -g wsrelayStarting the Server
The default port used is 8124, although you can pass a port number as an argument.
wsrelay [port]Connecting with wscat
You can test the server out using wscat, which is like the UNIX cat command but for websockets.
wscat --connect ws://localhost:8124Be sure to connect two wscats to the server to see it relaying messages.
Writing your own client
Alternatively, you can write your own websocket client in Javascript
var WebSocket = require('ws');
var ws = new WebSocket('ws://localhost:8124');
//print out all relay messages received
ws.onmessage = function(evt) {
var message = evt.data;
console.log(message);
}
//send all user input to the relay
process.stdin.on('data', function(data) {
ws.send(data.toString().trim());
});