WebRTC onicecandidate event

前端 未结 1 1025
予麋鹿
予麋鹿 2021-01-20 17:24

I have the following callback for the onicecandidate event of RTCPeerConnection:

function iceCallback(event) {
    if (event.candidate) {
        var candida         


        
相关标签:
1条回答
  • 2021-01-20 18:00

    I assumed that some part of your code would be like below, I have just added a simple modification:

    peerConnections ={};
    
    function createNewConncection(id){
        var pc = new RTCPeerConnection();
        pc.onaddstream = ...
        ...
    
        //pc.onicecandidate = iceCallback;  // OLD CODE
        pc.onicecandidate = iceCallback.bind({pc:pc, id:id});  // NEW CODE
        peerConnections[id] = pc;
    }
    
    function iceCallback(event) {
        if (event.candidate) {
            var candidate = event.candidate;
            //socSend("candidate", candidate. event.target.id);     // OLD CODE
            socSend("candidate", this.id);          // NEW CODE
        }
    }
    
    0 讨论(0)
提交回复
热议问题