W3C home > Mailing lists > Public > public-webrtc@w3.org > June 2013

Re: Futures in WebRTC

From: Jan-Ivar Bruaroey <jib@mozilla.com>
Date: Tue, 04 Jun 2013 11:09:41 -0400
Message-ID: <51AE0335.3080001@mozilla.com>
To: public-webrtc@w3.org
On 6/3/13 6:09 PM, cowwoc wrote:
>> Is that about right?
>     Almost. This code doesn't make sense to me: 
> "then(pc2.setRemoteDescription(offer););"
>
>     then() expects you to pass in a callback. 
> "pc2.setRemoteDescription(offer)" returns a Future, not a callback. I 
> think you'd have to surround the call with "function(){}" to fix the code.

Thanks for catching that.

function simpletest_newapi() {
   var pc1 = new RTCPeerConnection();
   var pc2 = new RTCPeerConnection();

   navigator.GetUserMedia({video:true})
     .then(function(video1) {
       pc1.addStream(video1);
       return pc1.createOffer();
     })
     .then(function(offer) {
       return pc1.setLocalDescription(offer)
         .then(function() { return pc2.setRemoteDescription(offer); });
     })
     .then(pc2.createAnswer())
     .then(function(answer) {
       return pc2.setLocalDescription(answer)
         .then(function() { return pc1.setRemoteDescription(answer); });
     })
     .then(finish, fail);
}

.: Jan-Ivar :.

> Gili
Received on Tuesday, 4 June 2013 15:10:11 UTC

This archive was generated by hypermail 2.3.1 : Monday, 23 October 2017 15:19:33 UTC