@@ -31,7 +31,7 @@ class Signaling {
31
31
var _url;
32
32
var _name;
33
33
var _peerConnections = new Map <String , RTCPeerConnection >();
34
- var _daChannels = new Map <String , RTCDataChannel >();
34
+ var _dataChannels = new Map <String , RTCDataChannel >();
35
35
MediaStream _localStream;
36
36
List <MediaStream > _remoteStreams;
37
37
SignalingStateCallback onStateChange;
@@ -93,9 +93,9 @@ class Signaling {
93
93
if (_socket != null ) _socket.close ();
94
94
}
95
95
96
- void switchCamera (){
97
- if (_localStream != null ){
98
- _localStream.getVideoTracks ()[0 ].switchCamera ();
96
+ void switchCamera () {
97
+ if (_localStream != null ) {
98
+ _localStream.getVideoTracks ()[0 ].switchCamera ();
99
99
}
100
100
}
101
101
@@ -189,7 +189,7 @@ class Signaling {
189
189
{
190
190
var id = data;
191
191
_peerConnections.remove (id);
192
- _daChannels .remove (id);
192
+ _dataChannels .remove (id);
193
193
194
194
if (_localStream != null ) {
195
195
_localStream.dispose ();
@@ -224,6 +224,13 @@ class Signaling {
224
224
pc.close ();
225
225
_peerConnections.remove (to);
226
226
}
227
+
228
+ var dc = _dataChannels[to];
229
+ if (dc != null ) {
230
+ dc.close ();
231
+ _dataChannels.remove (to);
232
+ }
233
+
227
234
this ._sessionId = null ;
228
235
if (this .onStateChange != null ) {
229
236
this .onStateChange (SignalingState .CallStateBye );
@@ -287,7 +294,9 @@ class Signaling {
287
294
}
288
295
};
289
296
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);
291
300
if (this .onLocalStream != null ) {
292
301
this .onLocalStream (stream);
293
302
}
@@ -310,8 +319,7 @@ class Signaling {
310
319
});
311
320
};
312
321
313
- pc.onIceConnectionState = (state) {
314
- };
322
+ pc.onIceConnectionState = (state) {};
315
323
316
324
pc.onAddStream = (stream) {
317
325
if (this .onAddRemoteStream != null ) this .onAddRemoteStream (stream);
@@ -338,10 +346,9 @@ class Signaling {
338
346
if (this .onDataChannelMessage != null )
339
347
this .onDataChannelMessage (channel, data);
340
348
};
341
- _daChannels [id] = channel;
349
+ _dataChannels [id] = channel;
342
350
343
- if (this .onDtaChannel != null )
344
- this .onDtaChannel (channel);
351
+ if (this .onDtaChannel != null ) this .onDtaChannel (channel);
345
352
}
346
353
347
354
_createDataChannel (id, RTCPeerConnection pc, {label: 'fileTransfer' }) async {
0 commit comments