Browse Source

userId改成name

lincl 4 years ago
parent
commit
80276d08b1
1 changed files with 12 additions and 11 deletions
  1. 12 11
      src/components/videoChat/video-chat.vue

+ 12 - 11
src/components/videoChat/video-chat.vue

@ -161,10 +161,11 @@ export default {
                return {
                        "iceServers":[
                            {
                                urls:"stun:47.110.140.238:3478"
                                urls:"stun:27.154.233.186:3478"
                            },
                            {
                                urls:["turn:47.110.140.238:3478"],
                                url:"turn:27.154.233.186:3478",
                                urls:["turn:27.154.233.186:3478"],
                                username:"kurento",
                                credential: "kurento"
                            }
@ -313,7 +314,7 @@ export default {
                    vm.receiveVideoResponse(parsedMessage);
                    break;
                case 'iceCandidate':
                    vm.participants[parsedMessage.userId].rtcPeer.addIceCandidate(parsedMessage.candidate, function (error) {
                    vm.participants[parsedMessage.name].rtcPeer.addIceCandidate(parsedMessage.candidate, function (error) {
                        if (error) {
                        console.error("Error adding candidate: " + error);
                        return;
@ -363,8 +364,8 @@ export default {
        register(){
            var message = {
                id : 'joinRoom',
                userId : this.userCode,
                roomId : this.sessionId,
                name : this.userCode,
                room : this.sessionId,
            }
            console.log(this.ws.readyState);
            if (this.ws.readyState===1) {
@ -395,12 +396,12 @@ export default {
        },
        onNewParticipant(request) {
            // console.log("onNewParticipant", request);
            this.receiveVideo(request.userId);
            this.receiveVideo(request.name);
        },
        receiveVideoResponse(result) {
            debugger
            // console.log("receiveVideoResponse", result);
            this.participants[result.userId].rtcPeer.processAnswer (result.sdpAnswer, function (error) {
            this.participants[result.name].rtcPeer.processAnswer (result.sdpAnswer, function (error) {
                if (error) return console.error (error);
            });
        },
@ -474,10 +475,10 @@ export default {
        },
        onParticipantLeft(request) {
            debugger
            // console.log('onParticipantLeft Participant ' + request.userId + ' left');
            var participant1 = this.participants[request.userId];
            // console.log('onParticipantLeft Participant ' + request.name + ' left');
            var participant1 = this.participants[request.name];
            participant1.dispose();
            delete this.participants[request.userId];
            delete this.participants[request.name];
        },
        participant(code, vm){
            let container = document.getElementById("par_"+code),
@ -511,7 +512,7 @@ export default {
                    var message = {
                        id: 'onIceCandidate',
                        candidate: candidate,
                        userId: code
                        name: code
                    };
                    vm.sendMessage(message);
                },