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

@sofya-sdk/core

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

@sofya-sdk/core

Core WebSocket client for EventRooms messaging

latest
npmnpm
Version
1.0.1
Version published
Maintainers
1
Created
Source

@sofya-sdk/core

Core WebSocket client for EventRooms messaging with auto-reconnection.

Installation

pnpm add @sofya-sdk/core

Usage

import { EventRoomsClient } from '@sofya-sdk/core';

const client = new EventRoomsClient({
  url: 'wss://messaging.sofya.app/ws',
  roomId: 'ROOM123',
  role: 'desktop', // or 'mic'
  autoReconnect: true,
  maxReconnectAttempts: 5,
});

// Connect
client.connect();

// Listen to events
client.on('transcription', (payload) => {
  console.log('Transcription:', payload);
});

// Listen to presence
client.onPresence((presence) => {
  console.log('Clients in room:', presence.clientsLocal);
});

// Listen to errors
client.onError((error) => {
  console.error('Error:', error.message);
});

// Listen to connection state
client.onConnectionState((state) => {
  console.log('State:', state);
});

// Send events
client.sendEvent('transcription', { text: 'Hello', partial: false });

// Disconnect
client.disconnect();

API

Constructor

new EventRoomsClient(config: EventRoomsConfig)

Config:

  • url (string) - WebSocket URL
  • roomId (string) - Room ID
  • role ('desktop' | 'mic') - Client role
  • autoReconnect (boolean, optional) - Auto-reconnect on disconnect (default: true)
  • maxReconnectAttempts (number, optional) - Max reconnection attempts (default: 5)
  • reconnectDelay (number, optional) - Initial reconnection delay in ms (default: 1000)
  • maxReconnectDelay (number, optional) - Max reconnection delay in ms (default: 30000)

Methods

  • connect() - Connect to EventRooms
  • disconnect() - Disconnect from EventRooms
  • sendEvent(event, payload) - Send custom event
  • on(event, handler) - Listen to event (returns unsubscribe function)
  • onError(handler) - Listen to errors (returns unsubscribe function)
  • onPresence(handler) - Listen to presence updates (returns unsubscribe function)
  • onConnectionState(handler) - Listen to connection state changes (returns unsubscribe function)
  • getConnectionState() - Get current connection state
  • getRoomId() - Get room ID
  • getRole() - Get client role

Features

  • Auto-reconnection with exponential backoff
  • Ping/pong heartbeat to keep connection alive
  • Event name validation (regex + reserved names)
  • Type-safe event handlers
  • Connection state management

License

ISC

Keywords

websocket

FAQs

Package last updated on 27 Oct 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