8000 [iOS/macOS] Fix possible method call handling without result callback… · hicodeboy/flutter-webrtc@770fd70 · GitHub
[go: up one dir, main page]

Skip to content

Commit 770fd70

Browse files
committed
[iOS/macOS] Fix possible method call handling without result callback call
In this case, the future, which returned for method call, never complete. The current fix implements the same behavior as in Android implementation.
1 parent b7a2c6e commit 770fd70

File tree

2 files changed

+32
-36
lines changed

2 files changed

+32
-36
lines changed

ios/Classes/FlutterWebRTCPlugin.m

Lines changed: 16 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -377,25 +377,23 @@ - (void)handleMethodCall:(FlutterMethodCall*)call result:(FlutterResult) result
377377
NSString* peerConnectionId = argsMap[@"peerConnectionId"];
378378

379379
RTCPeerConnection *peerConnection = self.peerConnections[peerConnectionId];
380-
if (!peerConnection) {
381-
return;
382-
}
383-
[peerConnection close];
384-
[self.peerConnections removeObjectForKey:peerConnectionId];
385-
386-
// Clean up peerConnection's streams and tracks
387-
[peerConnection.remoteStreams removeAllObjects];
388-
[peerConnection.remoteTracks removeAllObjects];
389-
390-
// Clean up peerConnection's dataChannels.
391-
NSMutableDictionary<NSNumber *, RTCDataChannel *> *dataChannels
392-
= peerConnection.dataChannels;
393-
for (NSNumber *dataChannelId in dataChannels) {
394-
dataChannels[dataChannelId].delegate = nil;
395-
// There is no need to close the RTCDataChannel because it is owned by the
396-
// RTCPeerConnection and the latter will close the former.
380+
if (peerConnection) {
381+
[peerConnection close];
382+
[self.peerConnections removeObjectForKey:peerConnectionId];
383+
384+
// Clean up peerConnection's streams and tracks
385+
[peerConnection.remoteStreams removeAllObjects];
386+
[peerConnection.remoteTracks removeAllObjects];
387+
388+
// Clean up peerConnection's dataChannels.
389+
NSMutableDictionary<NSNumber *, RTCDataChannel *> *dataChannels = peerConnection.dataChannels;
390+
for (NSNumber *dataChannelId in dataChannels) {
391+
dataChannels[dataChannelId].delegate = nil;
392+
// There is no need to close the RTCDataChannel because it is owned by the
393+
// RTCPeerConnection and the latter will close the former.
394+
}
395+
[dataChannels removeAllObjects];
397396
}
398-
[dataChannels removeAllObjects];
399397
result(nil);
400398
} else if ([@"createVideoRenderer" isEqualToString:call.method]){
401399
NSDictionary* argsMap = call.arguments;

macos/Classes/FlutterWebRTCPlugin.m

Lines changed: 16 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -303,25 +303,23 @@ - (void)handleMethodCall:(FlutterMethodCall*)call result:(FlutterResult) result
303303
NSString* peerConnectionId = argsMap[@"peerConnectionId"];
304304

305305
RTCPeerConnection *peerConnection = self.peerConnections[peerConnectionId];
306-
if (!peerConnection) {
307-
return;
308-
}
309-
[peerConnection close];
310-
[self.peerConnections removeObjectForKey:peerConnectionId];
311-
312-
// Clean up peerConnection's streams and tracks
313-
[peerConnection.remoteStreams removeAllObjects];
314-
[peerConnection.remoteTracks removeAllObjects];
315-
316-
// Clean up peerConnection's dataChannels.
317-
NSMutableDictionary<NSNumber *, RTCDataChannel *> *dataChannels
318-
= peerConnection.dataChannels;
319-
for (NSNumber *dataChannelId in dataChannels) {
320-
dataChannels[dataChannelId].delegate = nil;
321-
// There is no need to close the RTCDataChannel because it is owned by the
322-
// RTCPeerConnection and the latter will close the former.
306+
if (peerConnection) {
307+
[peerConnection close];
308+
[self.peerConnections removeObjectForKey:peerConnectionId];
309+
310+
// Clean up peerConnection's streams and tracks
311+
[peerConnection.remoteStreams removeAllObjects];
312+
[peerConnection.remoteTracks removeAllObjects];
313+
314+
// Clean up peerConnection's dataChannels.
315+
NSMutableDictionary<NSNumber *, RTCDataChannel *> *dataChannels = peerConnection.dataChannels;
316+
for (NSNumber *dataChannelId in dataChannels) {
317+
dataChannels[dataChannelId].delegate = nil;
318+
// There is no need to close the RTCDataChannel because it is owned by the
319+
// RTCPeerConnection and the latter will close the former.
320+
}
321+
[dataChannels removeAllObjects];
323322
}
324-
[dataChannels removeAllObjects];
325323
result(nil);
326324
} else if ([@"createVideoRenderer" isEqualToString:call.method]){
327325
NSDictionary* argsMap = call.arguments;

0 commit comments

Comments
 (0)
0