Provides a form-fit-functional replacement for the notoriously buggy socket.io
and its socket.io-client client counterpart. Like its socket.io predecessors,
SocketIO provides json-based web sockets, though it also has hooks to support binary sockets (for VoIP, video, etc) applications.
SocketIO provides both a server-side and client-side modules that mimic the socket.io
specification (less the bugs of course).
Manage
npm install @totemstan/socketio # install
npm run start [ ? | $ | ...] # Unit test
npm run verminor # Roll minor version
npm run vermajor # Roll major version
npm run redoc # Regen documentation
Usage
Acquire SocketIO as follows:
const SIO = require("@totemstan/socketio");
See the Program Reference for examples.
Program Reference
Open/Close
## Modules
- SOCKETIO
Replaces the buggy socket.io and socket.io-client modules.
Documented in accordance with jsdoc.
ref: https://medium.com/hackernoon/implementing-a-websocket-server-with-node-js-d9b78ec5ffa8
- SOCKETIO-CLIENT
Replaces the buggy socket.io and socket.io-client modules found in the public.
SOCKETIO
Replaces the buggy socket.io and socket.io-client modules.
Documented in accordance with jsdoc.
ref: https://medium.com/hackernoon/implementing-a-websocket-server-with-node-js-d9b78ec5ffa8
Requires: module:@totemstan/enums, module:crypto
Author: ACMESDS
Example
On the server:
const SIO = require("socketio");
IO = SIO(server);
IO.on( "connect", socket => {
socket.on( "CHANNEL", (req,socket) => {
console.log( "here is the client's request", req );
socket.emit({ message: "a response" });
IO.emit({ message: "a message for everyone!" });
IO.emitOthers("SkipThisClient", { message: "a message for everyone!" });
IO.clients["someone@totem.org"].emit({ message: "you get an extra message"});
});
});
IO.emit({ .... })
On the client:
const
ioSocket = io();
ioClient = "myClientName";
ioSocket.emit("CHANNEL", {
...
});
ioSocket.on("CHANNEL", req => {
console.log("server sent this request", req);
});
Example
On the server:
const
SOCKETIO = require("socketio"),
SIO = SOCKETIO(server);
SIO.on("connect", socket => {
console.log("listening to sockets");
socket.on( "join", (req,socket) => {
});
});
On the client:
const
iosocket = io();
ioClient = "somewhere@org.com";
iosocket.emit( "join", {
client: ioClient,
message: "can I join please?"
});
SOCKETIO-CLIENT
Replaces the buggy socket.io and socket.io-client modules found in the public.
Author: ACMESDS
Contacting, Contributing, Following
Feel free to
License
MIT
© 2012 ACMESDS