Re: Question about sync / async for createOffer and createAnswer

+1 for async, and async always.

On 9 May 2012 09:44, Eric Rescorla <ekr@rtfm.com> wrote:
> Do I have to call setLocalDescription() from the callback? I.e., is this
> acceptable:
>
> pc.createOffer(function (offer) {
>   offer = tweakOffer(offer);
>   setTimeout(function() {
>      pc.setLocalDescription("offer", offer);
>      }, 1000);
>
>   // ...
>   }, hints);

Damn, I hope so.  This should be just a blob of data, and who knows
what you might need to do to "tweak" the offer.  Maybe you have that
logic on a server somewhere.

The only concern is if the conditions have changed in such a way that
the offer is available for a strictly limited time.  I suspect however
that this is always the case and setLocalDescription can fail, even
with an immediate call with unmodified offer.  If it takes 100ms to
get the info, some of the info could be up to that old when it
arrives, giving a 100ms window for stuff to happen (other tabs to grab
the camera, user to revoke permissions, etc...).  createOffer doesn't
create any commitment after all.

--Martin

Received on Wednesday, 9 May 2012 17:23:46 UTC