-
Notifications
You must be signed in to change notification settings - Fork 6
Socket.io P2P
Jasmine Falk edited this page Dec 9, 2018
·
16 revisions
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.
var io = require('socket.io')(server);
var p2p = require('socket.io-p2p-server').Server;
io.use(p2p);
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);
});
Full usage can be found here: https://github.com/socketio/socket.io-p2p