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

@iobroker/ws-server-library

v5.0.2

Published

This package allows to communicate different web applications with ioBroker.

Downloads

9,335

Readme

@iobroker/ws-server-library

Server-side library that exposes the ioBroker object/state API to browser clients over pure WebSockets.

This package is used by WEB applications and adapters to communicate with ioBroker using websockets.

It was extracted from the ioBroker.ws adapter so the same socket implementation can be shared by ioBroker.web and ioBroker.ws (and other WEB adapters).

It behaves almost like ioBroker.socketio, but does not use the socket.io library — since v4 the socket.io protocol is only simulated over native WebSockets.

This is a library, not an adapter. End users do not install it directly; it is a dependency of the WEB adapters listed above.

You can find in the example directory a simple application that uses this interface to show some data.

Usage

The library is consumed from inside an ioBroker adapter, after an HTTP(S) server and a session store already exist. The high-level entry point is IOSocketClass:

import { IOSocketClass } from '@iobroker/ws-server-library';
import type { SocketSettings, Store } from '@iobroker/socket-classes';

const io = new IOSocketClass(
    server,    // http.Server | https.Server the adapter already listens on
    settings,  // SocketSettings (from @iobroker/socket-classes)
    adapter,   // ioBroker.Adapter instance
    store,     // session Store (from @iobroker/socket-classes)
    checkUser, // optional (user, pass, cb) => void credential check
);

// broadcast to all connected clients
io.publishAll('stateChange', id, state);
io.publishFileAll(id, fileName, size);
io.sendLog(logMessage);

// on adapter unload
io.close();

The supported client-facing methods (the actual WebSocket protocol) are implemented in @iobroker/socket-classes. For the browser side use the socket client.

Exports

| Export | Description | |---|---| | IOSocketClass | High-level wrapper an adapter instantiates (see above). | | SocketWS | The SocketCommon subclass that implements the WS-specific auth, sessions and broadcasting. Use directly only for advanced cases. | | WebSocketClient | Type of a single client connection (re-exported from the @iobroker/ws-server transport). | | WsConfig | Type of the adapter native configuration (port, auth, secure, TLS certs, …). | | ./socket.io.js | The bundled @iobroker/ws browser client, so the consuming adapter can serve it to browsers. |

ioBroker concepts

By using this interface you should understand the basics and concept of the system, and the structure of the objects.

Object

An object is the description of a data point or a group. A group that contains other data points is a channel; a group of channels is a device. Objects are meta-information (min/max, unit, name, default value, value type, communication info, …).

State

A state is the actual value of a data point:

const state = {
    "val": VALUE,
    "ack": ACKNOWLEDGED,
    "ts": TIMESTAMP,                 // new Date(state.ts)
    "lc": TIMESTAMP_of_last_change,
    "from": ADAPTER_NAME,
    "q": QUALITY
};

States change far more frequently than objects (objects are normally written once, at creation).

Acknowledgment

Every state has an ack flag that shows the direction of the command:

  • ack=false — some adapter wants to control (write) the value, so the command will be executed (e.g. light will be switched on).
  • ack=true — the device informs about a new value (e.g. light was switched on manually, or motion was detected).

Quality

Every data point has a q (quality) attribute.

Changelog

5.0.2 (2026-06-20)

  • (@GermanBluefox) Initial commit. Extracted the socket implementation from the ioBroker.ws adapter into a shared library

License

The MIT License (MIT)

Copyright (c) 2014-2026 @GermanBluefox [email protected]