New Research: Supply Chain Attack on Axios Pulls Malicious Dependency from npm.Details →
Socket
Book a DemoSign in
Socket

wiaxy-realtime

Package Overview
Dependencies
Maintainers
1
Versions
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

wiaxy-realtime

Lightweight WebSocket wrapper with auto-reconnect, heartbeat, events and presence helpers

latest
npmnpm
Version
0.1.0
Version published
Weekly downloads
0
-100%
Maintainers
1
Weekly downloads
 
Created
Source

wiaxy-realtime

Lightweight WebSocket wrapper for browser environments.

Features

  • Auto reconnect with exponential backoff
  • Heartbeat ping/pong to detect dead connections
  • Event emit / on semantics using JSON messages
  • Presence helpers (room subscribe/join/leave)
  • Send queue while disconnected
  • Promise-based ack support

Install

npm install wiaxy-realtime

Quick usage

import { RealtimeClient } from "wiaxy-realtime";

const client = new RealtimeClient("wss://your-server.example/ws", {
  reconnection: { enabled: true, minDelay: 500, maxDelay: 20000 },
  heartbeat: { enabled: true, interval: 20000 }
});

client.on('__status', status => console.log('status', status));
client.on('chat.message', (m) => console.log('message', m));
client.on('__connected', () => console.log('connected'));

client.connect();

// emit an event
client.emit('chat.message', { text: 'Hello' });

// emit with ack (returns a Promise)
client.emit('chat.message', { text: 'Please ack me' }, { ack: true, timeout: 5000 })
  .then(resp => console.log('ack received', resp))
  .catch(err => console.error('ack failed', err));

// presence
client.subscribePresence('room:main', members => {
  console.log('room members:', members);
});
client.join('room:main');

Server contract

This library expects server messages in JSON form such as:

{ "event": "chat.message", "data": { "text": "Hello" } }

Control messages the client understands (you can implement these on server):

  • {"type":"__pong"} — heartbeat pong
  • {"type":"__clientId", "clientId":"..."}
  • {"type":"__presence", "room":"room", "members":["id1","id2"]}
  • Optionally you can use _ackId to request ack callbacks.

API

See index.d.ts for typed API.

License

MIT

Keywords

websocket

FAQs

Package last updated on 04 Nov 2025

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