diff --git a/im-ui/src/api/rtcGroupApi.js b/im-ui/src/api/rtcGroupApi.js index 58e8409..42fc4f0 100644 --- a/im-ui/src/api/rtcGroupApi.js +++ b/im-ui/src/api/rtcGroupApi.js @@ -1,18 +1,13 @@ import http from './httpRequest.js' -class RtcGroupApi { - constructor() { - this.http = http; - } -} - +class RtcGroupApi {} RtcGroupApi.prototype.setup = function(groupId, userInfos) { let formData = { groupId, userInfos } - return this.http({ + return http({ url: '/webrtc/group/setup', method: 'post', data: formData @@ -20,14 +15,14 @@ RtcGroupApi.prototype.setup = function(groupId, userInfos) { } RtcGroupApi.prototype.accept = function(groupId) { - return this.http({ + return http({ url: '/webrtc/group/accept?groupId='+groupId, method: 'post' }) } RtcGroupApi.prototype.reject = function(groupId) { - return this.http({ + return http({ url: '/webrtc/group/reject?groupId='+groupId, method: 'post' }) @@ -38,7 +33,7 @@ RtcGroupApi.prototype.failed = function(groupId,reason) { groupId, reason } - return this.http({ + return http({ url: '/webrtc/group/failed', method: 'post', data: formData @@ -47,7 +42,7 @@ RtcGroupApi.prototype.failed = function(groupId,reason) { RtcGroupApi.prototype.join = function(groupId) { - return this.http({ + return http({ url: '/webrtc/group/join?groupId='+groupId, method: 'post' }) @@ -58,7 +53,7 @@ RtcGroupApi.prototype.invite = function(groupId, userInfos) { groupId, userInfos } - return this.http({ + return http({ url: '/webrtc/group/invite', method: 'post', data: formData @@ -72,7 +67,7 @@ RtcGroupApi.prototype.offer = function(groupId, userId, offer) { userId, offer } - return this.http({ + return http({ url: '/webrtc/group/offer', method: 'post', data: formData @@ -85,7 +80,7 @@ RtcGroupApi.prototype.answer = function(groupId, userId, answer) { userId, answer } - return this.http({ + return http({ url: '/webrtc/group/answer', method: 'post', data: formData @@ -93,14 +88,14 @@ RtcGroupApi.prototype.answer = function(groupId, userId, answer) { } RtcGroupApi.prototype.quit = function(groupId) { - return this.http({ + return http({ url: '/webrtc/group/quit?groupId=' + groupId, method: 'post' }) } RtcGroupApi.prototype.cancel = function(groupId) { - return this.http({ + return http({ url: '/webrtc/group/cancel?groupId=' + groupId, method: 'post' }) @@ -112,7 +107,7 @@ RtcGroupApi.prototype.candidate = function(groupId, userId, candidate) { userId, candidate } - return this.http({ + return http({ url: '/webrtc/group/candidate', method: 'post', data: formData @@ -125,7 +120,7 @@ RtcGroupApi.prototype.device = function(groupId, isCamera, isMicroPhone) { isCamera, isMicroPhone } - return this.http({ + return http({ url: '/webrtc/group/device', method: 'post', data: formData @@ -139,7 +134,7 @@ RtcGroupApi.prototype.candidate = function(groupId, userId, candidate) { userId, candidate } - return this.http({ + return http({ url: '/webrtc/group/candidate', method: 'post', data: formData @@ -147,7 +142,7 @@ RtcGroupApi.prototype.candidate = function(groupId, userId, candidate) { } RtcGroupApi.prototype.heartbeat = function(groupId) { - return this.http({ + return http({ url: '/webrtc/group/heartbeat?groupId=' + groupId, method: 'post' }) diff --git a/im-ui/src/api/webrtc.js b/im-ui/src/api/webrtc.js index 359118b..8382cd1 100644 --- a/im-ui/src/api/webrtc.js +++ b/im-ui/src/api/webrtc.js @@ -33,9 +33,11 @@ ImWebRtc.prototype.setStream = function(stream) { if(this.stream){ this.peerConnection.removeStream(this.stream) } - stream.getTracks().forEach((track) => { - this.peerConnection.addTrack(track, stream); - }); + if(stream){ + stream.getTracks().forEach((track) => { + this.peerConnection.addTrack(track, stream); + }); + } this.stream = stream; } @@ -111,6 +113,7 @@ ImWebRtc.prototype.close = function(uid) { this.peerConnection.close(); this.peerConnection.onicecandidate = null; this.peerConnection.onaddstream = null; + this.peerConnection = null; } } diff --git a/im-ui/src/components/chat/ChatBox.vue b/im-ui/src/components/chat/ChatBox.vue index e9ea6b0..c58529d 100644 --- a/im-ui/src/components/chat/ChatBox.vue +++ b/im-ui/src/components/chat/ChatBox.vue @@ -44,7 +44,7 @@