You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Jasmine Falk edited this page Dec 9, 2018
·
16 revisions
Overview
Socket.IO P2P establishes a bidirectional events channel between two peers with a server fallback by setting up a WebRTC connection between peers and communicates using the socket.io-protocol.
Socket.IO is used to transport signaling data and as a fallback for clients where the WebRTC PeerConnection is not supported.
Usage
Server:
var io = require('socket.io')(server);
var p2p = require('socket.io-p2p-server').Server;
io.use(p2p);
Client:
var P2P = require('socket.io-p2p');
var io = require('socket.io-client');
var socket = io();
var p2p = new P2P(socket);
p2p.on('peer-msg', function (data) {
console.log('From a peer %s', data);
});