Custom Server with peerjs - no documentation has left me clueless

855 views Asked by At

My question is much like this guys... how to create and run my own peerjs server?

On the peerjs Quick Start you have the options of... Creating their server (Doesn't Work), or creating your own server(Does Work).

The documentation if you want to call it that has no help for how to handle a call in "server.js" if that's what you're calling it.

In the Source of, http://cdn.peerjs.com/demo/videochat/ on line 37, you make a "call"... Then what?

I have an index.html, that connects fine, I have a server.js that runs with no errors in node.... I can say Hello World all I want, but, How to Handle a Call, and Answer a call

http://jsfiddle.net/cbaftkzn/1/

$('#make-call').click(function(){
    var call = peer.call($('#callto-id').val(), window.localStream);
    step3(call);
});

A Frustrated Thank you...

1

There are 1 answers

0
sousa On

You don't handle calls in the server.js file. The peer server is only for signalling. See this basic signalling server

You just need this to connect browser peers and make video connections among them.

Try the examples on peerjs.com and work your way up, ie:

make a call:

var getUserMedia = navigator.getUserMedia || navigator.webkitGetUserMedia || navigator.mozGetUserMedia;
getUserMedia({video: true, audio: true}, function(stream) {
  var call = peer.call('another-peers-id', stream);
  call.on('stream', function(remoteStream) {
    // Show stream in some video/canvas element.
  });
}, function(err) {
  console.log('Failed to get local stream' ,err);
});

receive a call:

var getUserMedia = navigator.getUserMedia || navigator.webkitGetUserMedia || navigator.mozGetUserMedia;
peer.on('call', function(call) {
  getUserMedia({video: true, audio: true}, function(stream) {
    call.answer(stream); // Answer the call with an A/V stream.
    call.on('stream', function(remoteStream) {
      // Show stream in some video/canvas element.
    });
  }, function(err) {
    console.log('Failed to get local stream' ,err);
  });
});