npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@mikosoft/ws-client-browser

v1.2.6

Published

Websocket Client for browser which works best with the Mikosoft Websocket Server.

Readme

@mikosoft/ws-client-browser

Websocket Client for browser which works best with the Mikosoft Websocket Server - @mikosoft/ws-server.

Small but very powerful library made according to RFC6455 Standard for websocket version 13.

Website Documentation

http://libs.mikosoft.info/websocket/ws-client-browser

Websocket Client for Browser Features

  • websocket version: 13
  • subprotocol: jsonRWS, raw
  • automatic reconnect
  • chat in the rooms
  • small file size, minified (~7.5kB only)
  • powerful API
  • possible RxJS integration
  • use it with webpack builds

Installation

npm install --save @mikosoft/ws-client-browser

Howto Use

There are two ways to use it in your project:

  • script in HTML
<script src="/node_modules/@mikosoft/ws-client-browser/dist/wsClientBrowser.min.js"></script>
// now fetch it as window.mikosoft global variable
const wsClient = new window.mikosoft.WsClientBrowser(wsOpts);
await wsClient.connect('ws://localhost:3211?authkey=TRTmrt'); // open websocket connection
  • import in JS
import { WsClientBrowser } from '@mikosoft/ws-client-browser';

const wsClient = new WsClientBrowser(wsOpts);
await wsClient.connect('ws://localhost:3211?authkey=TRTmrt'); // open websocket connection

API

  • connect(wsURL) - connect to the websocket server

  • disconnect() - disconnect from the websocket server

  • sendOne(to:string, msg:any) - send message to one websocket socket/client (parameter to is the socket ID)

  • send(to:string[], msg:any) - send message to one or more clients

  • broadcast(msg:any) - send message to all clients except the sender

  • sendAll(msg:any) - send message to all clients and the sender

  • questionSocketId() - receive the client's socket id

  • questionSocketList() - receive the list of sockets connected on the server

  • questionRoomList() - receive the list of all rooms

  • questionRoomListmy() - receive the list of subscribed rooms

  • roomEnter(roomName:string) - enter the room and start to listen the room's messages

  • roomExit(roomName:string) - exit from the room and stop to listen the room's messages

  • roomExitAll() - exit from the all rooms

  • roomSend(roomName:string, msg:any) - exit from the room and stop to listen the room's messages

  • setNick(nickname:string) - set the client's nickname

  • route(uri:string, body?:any) - send route to the server, for example: {uri: '/login', body: {username: 'john', password: 'trtmrt'}}

  • on(eventName:string, listener:Function) - listen events: 'connected', 'disconnected', 'message', 'message-error', 'route', 'question', 'server-error'

  • once(eventName:string, listener:Function) - listen events: 'connected', 'disconnected', 'message', 'message-error', 'route', 'question', 'server-error' only once

  • off(eventName:string, listener:Function) - stop listening the event for specific listener

  • offAll(eventName:string) - stop listening all the events

Example

import { WsClientBrowser } from '@mikosoft/ws-client-browser';


class WsLib {

  constructor() {
    const wsOpts = {
        connectTimeout: 8000, // HTTP request timeout i.e. websocket connect timeout (when internet is down or on localhost $ sudo ip link set lo down)
        reconnectAttempts: 12, // try to reconnect n times
        reconnectDelay: 5000, // delay between reconnections
        questionTimeout: 13 * 1000, // wait for answer
        subprotocols: ['jsonRWS'],
        debug: false,
        debug_DataParser: false
      };
      // <script src="/node_modules/@mikosoft/ws-client-browser/dist/WsClientBrowser.min.js"></script>
      this.wsClient = new window.mikosoft.WsClientBrowser(wsOpts);
  }


  // open websocket connection
  async konekt() {
    // connection listener
    this.wsClient.on('connected', () => {
      console.log('Websocket is connected.');
    });

    // disconnection listener
    this.wsClient.on('disconnected', () => {
      console.log('Websocket is disconnected.');
    });

    // open websocket connection
    const wsURL = 'ws://localhost:3211?authkey=TRTmrt';
    await this.wsClient.connect(wsURL);

  }


  // close websocket connection
  async diskonekt() {
    if (!!this.wsClient) { this.wsClient.disconnect(); }
  }


}



export default new WsLib();

Development and Build

If you want to participate in developing of the library:

$ npm run inst  # Install required dependencies and devDependencies
$ npm run dev   # This command will watch for /src/ file changes and build in /dist/ folder

Licence

Copyright (c) 2021 Mikosoft licensed under MIT .