1.0.6 • Published 3 months ago

vin-socket.server v1.0.6

Weekly downloads
-
License
ISC
Repository
github
Last release
3 months ago

VIN-SOCKET.SERVER

is NodeJS module, a websocket server side connection that minified the functionalities and strategies of ws for easy implementation of websocket.

This module required to install its peer module vin-socket.client to client side in order to work correctly.

Installation

npm install vin-socket.server

Features

  • easy to understand
  • modern approach
  • background digestion into binary data

Usage Examples

Emit to client

const { createServer } = require("http");
const { SocketServer } = require("vin-socket.server");

const server = createServer().listen(4000);
const wsServer = new SocketServer({ path: "/", server });

wsServer.onConnect((client) => {
  const client_id = client.getId();

  client.emit("res:message", {
    message: `Hello new client-${client_id}!`
  })
});

Listen to client

...
wsServer.on("req:message", (payload, client) => {
  const client_id = client.getId();
  console.log(`Received payload from client-${client_id}`, payload)
});

Join to room

...
client.join('room1')

Emit to room

...
client.to('room1').emit({
    message: "Hello to all inside of this room"
})

Contributing

Unfortunately we are not accepting any contributors yet this is under probitionary, but for your concerns and possible suggestions just email me at petatemarvin26@gmail.com

Changelog

We're using github release and based on semantic versioning

License

ISC

1.0.6

3 months ago

1.0.5

11 months ago

1.0.4

11 months ago

1.0.3

11 months ago

1.0.2

12 months ago

1.0.1

12 months ago

1.0.0

1 year ago