Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

bestws

Package Overview
Dependencies
Maintainers
1
Versions
2
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

bestws

Best WebSocket library, long gone are the days of the idiotic Socket.io

  • 1.0.0
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
0
decreased by-100%
Maintainers
1
Weekly downloads
 
Created
Source

BestWS

The best WebSocket library for fast, small send size, binary protocols.
Long gone is Socket.io's slow and stringified packets.

Time to use small and fast binary protocols

Quick server-client example

const bws = require("bestws");

const server = new bws.Server(bws.new.HTTP(3000));

server.on("initialize", (ws, res, init, req) => {
    console.log("Initial data received: ", init);
    res(["I", { got: "the" }, "message", 1111, [",", "you", { may: "connect" }, true]]);

    ws.on("message", (data) => {
        console.log("Got data from client: ", data);
        ws.send("Hello!");
    });
});

server.on("listening", () => {
    console.log("Listening.");
    const client = new bws.Client("ws://localhost:3000", [1, { a: "Init request data" }, 2]);
    client.on("initializing", () => console.log("Client connecting..."));
    client.on("open", (init) => {
        console.log("Server sent their own initial data: ", init);
        client.send("Hi!");
    });
    client.on("message", (data) => {
        console.log("Got data from server: ", data);
    });
});

Warning

I didn't make the above work with browsers, NodeJS only.

However,

Where this library shines if the encoding functionality which I haven't made in browser either, kinda too lazy for that. Have fun.

Keywords

FAQs

Package last updated on 05 Dec 2021

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc