MasterOdin / yaws-client

Yet Another WebSocket Client

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

YAWS-Server

Build Status

Yet Another Web Socket Server

A wrapper around the immensely wonderful websockets/ws that adds some needed utility I find myself always re-implement in usage, such as wrapping JSON messaging with stringify and parse methods, easy broadcasting, etc.

Installation

npm install yaws-server

Usage

const YawsServer = require('yaws-server');
const { createServer } = require('http');

const wsServer = new YawsServer(createServer());
wsServer.on('connection', (client) => {
  client.send('hello', {msg: 'world'});
  client.on('hello', (data) => {
    console.log(data);
  });
});

wsServer.broadcast('hello', {msg: 'world'});

About

Yet Another WebSocket Client

License:MIT License


Languages

Language:TypeScript 80.0%Language:JavaScript 20.0%