Sin descripción

ericz 83f87033ee move hace 12 años
bin 83f87033ee move hace 12 años
demo 83f87033ee move hace 12 años
dist 83f87033ee move hace 12 años
lib 83f87033ee move hace 12 años
.gitmodules f4affe47ce deleted msgpack. NEXT TODO: fix originator handlers hace 12 años
README.md 1f7a528ef6 readme hace 12 años
package.json 83f87033ee move hace 12 años

README.md

Peers: a node.js PeerConnection library

Under heavy development and testing.

Chrome

  • Run Canary with --enable-data-channel

Firefox

  • Firefox flags: media.navigator.enabled: true media.navigator.permission.disabled: true media.peerconnection.enabled: true

Usage

Server

npm install peer

var PeerServer = require('peer').PeerServer({ port: 80, debug: true });

Client

<script type="text/javascript" src="/client/dist/peer.js"></script>

Source Peer

originator = new SinkPeer({ video: true, audio: true, ws: 'ws://www.host.com' });
originator.on('ready', function(id) {
  console.log(id);
});
originator.on('connection', function(recipient) {
  // Sends a message to the other peer. This can even be a blob or JSON.
  originator.send('Hi there!');
  originator.send({ file: new Blob([1, 2, 3])});
});
originator.on('data', function(data) {
  // Prints out any messages received.
  console.log(data);
});

Sink Peer

// Sinks start off with an ID of whom to connect to.
sink = new SinkPeer({ source: source_id, ws: 'ws://localhost' });

Other events

  • localstream, remotestream: Callback is called with type, stream when a local or remote stream is added.

  • disconnect: Called with id when a peer disconnects. (TODO)