Skip to content

Commit 8b4af0f

Browse files
committed
Update.
1 parent bde6dc8 commit 8b4af0f

File tree

1 file changed

+18
-11
lines changed

1 file changed

+18
-11
lines changed

lib/src/call_sample/signaling.dart

Lines changed: 18 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ class Signaling {
3131
var _url;
3232
var _name;
3333
var _peerConnections = new Map<String, RTCPeerConnection>();
34-
var _daChannels = new Map<String, RTCDataChannel>();
34+
var _dataChannels = new Map<String, RTCDataChannel>();
3535
MediaStream _localStream;
3636
List<MediaStream> _remoteStreams;
3737
SignalingStateCallback onStateChange;
@@ -93,9 +93,9 @@ class Signaling {
9393
if (_socket != null) _socket.close();
9494
}
9595

96-
void switchCamera(){
97-
if(_localStream != null){
98-
_localStream.getVideoTracks()[0].switchCamera();
96+
void switchCamera() {
97+
if (_localStream != null) {
98+
_localStream.getVideoTracks()[0].switchCamera();
9999
}
100100
}
101101

@@ -189,7 +189,7 @@ class Signaling {
189189
{
190190
var id = data;
191191
_peerConnections.remove(id);
192-
_daChannels.remove(id);
192+
_dataChannels.remove(id);
193193

194194
if (_localStream != null) {
195195
_localStream.dispose();
@@ -224,6 +224,13 @@ class Signaling {
224224
pc.close();
225225
_peerConnections.remove(to);
226226
}
227+
228+
var dc = _dataChannels[to];
229+
if (dc != null) {
230+
dc.close();
231+
_dataChannels.remove(to);
232+
}
233+
227234
this._sessionId = null;
228235
if (this.onStateChange != null) {
229236
this.onStateChange(SignalingState.CallStateBye);
@@ -287,7 +294,9 @@ class Signaling {
287294
}
288295
};
289296

290-
MediaStream stream = user_screen? await navigator.getDisplayMedia(mediaConstraints) : await navigator.getUserMedia(mediaConstraints);
297+
MediaStream stream = user_screen
298+
? await navigator.getDisplayMedia(mediaConstraints)
299+
: await navigator.getUserMedia(mediaConstraints);
291300
if (this.onLocalStream != null) {
292301
this.onLocalStream(stream);
293302
}
@@ -310,8 +319,7 @@ class Signaling {
310319
});
311320
};
312321

313-
pc.onIceConnectionState = (state) {
314-
};
322+
pc.onIceConnectionState = (state) {};
315323

316324
pc.onAddStream = (stream) {
317325
if (this.onAddRemoteStream != null) this.onAddRemoteStream(stream);
@@ -338,10 +346,9 @@ class Signaling {
338346
if (this.onDataChannelMessage != null)
339347
this.onDataChannelMessage(channel, data);
340348
};
341-
_daChannels[id] = channel;
349+
_dataChannels[id] = channel;
342350

343-
if(this.onDtaChannel != null)
344-
this.onDtaChannel(channel);
351+
if (this.onDtaChannel != null) this.onDtaChannel(channel);
345352
}
346353

347354
_createDataChannel(id, RTCPeerConnection pc, {label: 'fileTransfer'}) async {

0 commit comments

Comments
 (0)