UNPKG

socket.iortc

Version:

socket.iortc is a library that combines WebRTC and Socket.IO to facilitate real-time communication. This library uses UDP protocol for data transfer using WebRTC ensuring low-latency and efficient communication.

44 lines (35 loc) 1.21 kB
declare module 'socketrtc' { import { Server as HTTPServer } from 'http'; import { Server as IOServer } from 'socket.io'; import SimplePeer from 'simple-peer'; interface SocketConfig { url?: string; server?: HTTPServer | IOServer; } interface RTCConfig { initiator?: boolean; wrtc?: any; [key: string]: any; } interface EventListener { (data?: any): void; } class SocketRTC { id: string; socket: any; events: { [key: string]: EventListener[] }; config: RTCConfig; clients: { [key: string]: SimplePeer.Instance }; constructor(socketConfig: SocketConfig, id?: string, rtcconfig?: RTCConfig); on(event: "connect" | "disconnect" | "message" | "error", listener: EventListener): void; emit(event: "connect" | "disconnect" | "message" | "error", ...args: any[]): void; send(data: any): void; except(id: string): { send: (data: any) => void; emit: (event: string, ...args: any[]) => void; }; private initializeServer(): void; private initializeClient(): void; } export = SocketRTC; }