2013-08-22 19 views
0

我正在嘗試在導入用戶的自定義應用中使用您的api。 一切工作正常(auth_token,登錄,呼叫啓動),但是當被調用者應該得到一個響應並添加remotestream什麼都不會發生。沒有錯誤顯示在控制檯中。 如果有人看看代碼並告訴我我錯過了什麼,我將不勝感激。 我試過了https://freeofcinema.vline.com的vline demo,它在兩臺計算機之間使用了相同的瀏覽器和條件。在我的應用程序中,它是一個http,但我也用https試過了,同樣的問題出現了。這是我用來測試api的一些簡化代碼。vline爲被調用者添加遠程流失

var Streams = []; 
var Vsession = null; 
var Vline = (function(){ 
    var Client; 
    var authToken; 
    var service_id = 'freeofcinema'; 
    var profile = null; 
    var Person; 
    var Calls = []; 

var onMessage = function(event){ 
    //alert('message'); 
    var msg = event.message, sender = msg.getSender(); 
    console.log(sender.getDisplayName() +'sais: '+ msg.getBody()); 
    console.log(event); 
} 
var onMediaSession = function(event){ 
    console.log(event); 
    var mediaSession = event.target; 
    InitSession(mediaSession); 
} 

function Call(mediaSession) { 
    mediaSession. 
    on('change', alert_info); 
} 

function alert_info(b){ 
    console.log(b); 
} 

function InitSession(mediaSession){ 
    mediaSession.on('mediaSession:addRemoteStream', function(event) { 
     alert('addRemoteStream'); 
    }); 
    mediaSession.on('mediaSession:addLocalStream', function(event) { 
     alert('addLocalStream'); 
    }); 
    mediaSession.on('mediaSession:removeLocalStream mediaSession:removeRemoteStream', function(event) { 
     console.log('removedStream'); 
    }); 
    Calls.push(new Call(mediaSession)); 
} 

return { 
    init : function(){ 
     if(profile){ 
      return; 
     } 
     profile = { 
      "displayName" : //some getusrname function... 
     }; 
     $.post('vtoken.php',{//get auth token 
      id : Comm.Voip_user().id 
     },function(data){ 
      authToken = data; 
      Client = vline.Client.create({ 
       "serviceId": service_id, 
       "ui" : true 
      }); 
      Client.on('recv:im', onMessage , this); 
      Client.on('add:mediaSession', onMediaSession, this); 
      Client.on('login', function(e) { 
       Vsession = e.target; 
       //alert('loged in'); 
      }); 
      Client.login(service_id, profile, authToken); 
     }); 
    }, 
    getPerson : function(id){//id of user to call 
     if(Vsession){ 
      Vsession.getPerson(id). 
      done(function(person){ 
       Person = person; 
       Vsession.startMedia(id); 
      }); 
     } 
    } 
} 
}()); 

感謝您的回覆。

我嘗試了一個用戶從應用程序,另一個從https://freeofcinema.vline.com,並出現同樣的問題。此外,呼叫(待定狀態)在短時間後終止。

回答

1

在創建客戶端時傳遞ui:true時,您不必親自處理媒體會話。只是評論行

Client.on('add:mediaSession', onMediaSession, this);
,它應該只是工作。