SkillAgentSearch skills...

P2pchat

Video & audio chat in less than 200 lines of JS :satellite:

Install / Use

/learn @philipjscott/P2pchat
About this skill

Quality Score

0/100

Supported Platforms

Universal

README

node-rtc-signal

Barebones example on how to accomplish P2P audio/video chat in under 200 lines of JS code. Demo page: https://philipjscott.github.io/node-rtc-signal/

I recommend trying it out by visiting it on your PC and on your phone :smiley:

How does it work?

node-rtc-signal uses Colyseus for signalling, and simple-peer for establishing P2P connections.

  • When a client joins, the signaling server broadcasts a message to every other client (see room.js)
  • Each client creates a Peer object and sends "signal data" (think of a "P2P address") to the server (see client/app.js)
  • The server relays all the signal data to the client that joined, who creates a Peer object for each address
  • Finally, the client that joined sends their signal data to all the other clients and establish a P2P connection

In other words, this algorithm constructs a full-mesh topology:

full-mesh

Unfortunately, full-mesh topologies don't scale well; given n peers, there will be n(n-1)/2 edges. This application begins to lag around ~5 clients. I've capped the maximum number of clients in a room to 4 (see config/default.json).

Running locally

git clone git@github.com:ScottyFillups/node-rtc-signal.git
yarn install
yarn run dev

A browser window should automatically open at http://localhost:1234

View on GitHub
GitHub Stars28
CategoryContent
Updated6mo ago
Forks4

Languages

JavaScript

Security Score

67/100

Audited on Aug 27, 2025

No findings