yanstv
yanstv

Reputation: 157

Webrtc.Peerconnection using PeerJs

It's my first time to work with PeerJs for WEBRTC.I have a problem for call another person.

Here is my code:

navigator.getUserMedia = navigator.getUserMedia || navigator.webkitGetUserMedia || navigator.mozGetUserMedia;

        var peer = new Peer($.jStorage.get('numero'), {host:'localhost', port:9000,debug: 3});


        peer.on('open', function(id) {
          console.log('My peer ID is: ' + id);

        });


        function bell(numero)  
        {
            navigator.getUserMedia({video: true, audio: true}, function(stream) {


                     var localStream = window.URL.createObjectURL(stream);               


                     $('#my_self').attr('src',localStream);

                     var call = peer.call(numero,stream);

                        call.on('stream', function(remoteStream) {


                            $('#caller').attr('src',remoteStream);
                        });

                        call.on('error', function(err) {

                          //error   
                        });

                },
                function(err) {

                            //errr

                    }

                }
            );
        }


        peer.on('call', function(call) {

                navigator.getUserMedia({video: true, audio: true}, function(stream) {


                     var localStream;= window.URL.createObjectURL(stream);


                      call.answer(localStream); 

                        call.on('stream', function(remoteStream) {


                         $('#caller').attr('src',remoteStream);
                        });

                    }, function(err) {

                     //err
                        }


                    }
                );
        });

I get this error when I call the bell(numero) function

Uncaught TypeError: Object # has no method 'call'

The problem is this line in my code var call = peer.call(numero,stream);

what is wrong?

I'm not connected to internet and I use peerjs for signaling,and in my node server,I write this

var PeerServer = require('peer').PeerServer;
var server = new PeerServer({ port: 9000 });

I asked the problem in their Google group but not response yet.

PLease help

Upvotes: 0

Views: 1418

Answers (1)

Tom Davies
Tom Davies

Reputation: 899

Just ran into this issue myself, are you using the 'peer.min.js' file? From looking at the source of it, it's version 0.2.8 whereas the 'peer.js' file hosted on their CDN is version 0.3.6.

When I switched to the version hosted at http://cdn.peerjs.com/0.3/peer.js, this problem went away.

Upvotes: 1

Related Questions