RTCMultiConnection Socket.io Server

1.3.3 · maintenance · verified Sun Apr 19

RTCMultiConnection Socket.io Server (npm package `rtcmulticonnection-server`) is a server-side component designed to facilitate real-time communication using WebRTC, specifically for the RTCMultiConnection client-side library. Its primary function is to manage signaling over a Socket.io connection, enabling peers to discover each other and exchange necessary session descriptions and ICE candidates to establish peer-to-peer WebRTC connections. The current stable version is 1.3.3, though the most significant feature change occurred in version 1.3.1. This package does not follow a strict, frequent release cadence, with major updates appearing intermittently as needed to support the core RTCMultiConnection library. A key differentiator since version 1.3.1 is its shift from being an independent server application to a modular component that integrates seamlessly into existing Node.js applications that already utilize Socket.io. This design choice allows developers greater flexibility in incorporating WebRTC signaling into their custom server architectures, rather than being forced into a standalone solution. It specifically avoids creating its own HTTP or Socket.io servers, delegating that responsibility to the host application.

Common errors

Warnings

Install

Imports

Quickstart

This example demonstrates how to integrate `rtcmulticonnection-server` into an existing Node.js HTTP server using `socket.io` for signaling, which is the recommended approach since version 1.3.1.

const http = require('http');
const { Server } = require('socket.io');
const RTCMultiConnectionServer = require('rtcmulticonnection-server');

const app = http.createServer((req, res) => {
    res.writeHead(200, { 'Content-Type': 'text/plain' });
    res.end('RTCMultiConnection Server running. Connect via Socket.io.\n');
});

const io = new Server(app, {
    cors: {
        origin: "*", // Adjust for production security
        methods: ["GET", "POST"]
    }
});

io.on('connection', (socket) => {
    console.log('Client connected:', socket.id);
    RTCMultiConnectionServer.addSocket(socket);

    socket.on('disconnect', () => {
        console.log('Client disconnected:', socket.id);
    });
});

const PORT = process.env.PORT || 9001;
app.listen(PORT, () => {
    console.log(`Server listening on port ${PORT}`);
});

view raw JSON →