浏览代码

Put open true in more sensible locations for MediaConnection

ericz 11 年之前
父节点
当前提交
191c0a8b6d
共有 1 个文件被更改,包括 4 次插入2 次删除
  1. 4 2
      lib/mediaconnection.js

+ 4 - 2
lib/mediaconnection.js

@@ -33,7 +33,7 @@ MediaConnection.prototype.addStream = function(remoteStream) {
 
 
   this.remoteStream = remoteStream;
   this.remoteStream = remoteStream;
   this.emit('stream', remoteStream); // Should we call this `open`?
   this.emit('stream', remoteStream); // Should we call this `open`?
-  this.open = true;
+
 };
 };
 
 
 MediaConnection.prototype.handleMessage = function(message) {
 MediaConnection.prototype.handleMessage = function(message) {
@@ -43,6 +43,7 @@ MediaConnection.prototype.handleMessage = function(message) {
     case 'ANSWER':
     case 'ANSWER':
       // Forward to negotiator
       // Forward to negotiator
       Negotiator.handleSDP(message.type, this, payload.sdp);
       Negotiator.handleSDP(message.type, this, payload.sdp);
+      this.open = true;
       break;
       break;
     case 'CANDIDATE':
     case 'CANDIDATE':
       Negotiator.handleCandidate(this, payload.candidate);
       Negotiator.handleCandidate(this, payload.candidate);
@@ -55,7 +56,7 @@ MediaConnection.prototype.handleMessage = function(message) {
 
 
 MediaConnection.prototype.answer = function(stream) {
 MediaConnection.prototype.answer = function(stream) {
   if (this.localStream) {
   if (this.localStream) {
-    // Throw some error.
+    util.warn('Local stream already exists on this MediaConnection. Are you answering a call twice?');
     return;
     return;
   }
   }
 
 
@@ -66,6 +67,7 @@ MediaConnection.prototype.answer = function(stream) {
     this,
     this,
     this.options._payload
     this.options._payload
   )
   )
+  this.open = true;
 };
 };
 
 
 /**
 /**