8000 Fix handling of unimplemented method · commetchat/flutter-webrtc@044714e · GitHub
[go: up one dir, main page]

Skip to content

Commit 044714e

Browse files
committed
Fix handling of unimplemented method
1 parent 81d3d84 commit 044714e

File tree

3 files changed

+12
-6
lines changed

3 files changed

+12
-6
lines changed

common/cpp/include/flutter_frame_cryptor.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,9 +23,11 @@ class FlutterFrameCryptor {
2323
public:
2424
FlutterFrameCryptor(FlutterWebRTCBase* base) : base_(base) {}
2525

26+
// Since this takes ownership of result, ownership will be passed back to 'outResult' if this function fails
2627
bool HandleFrameCryptorMethodCall(
2728
const MethodCallProxy& method_call,
28-
std::unique_ptr<MethodResultProxy> result);
29+
std::unique_ptr<MethodResultProxy> result,
30+
std::unique_ptr<MethodResultProxy> *outResult);
2931

3032
void FrameCryptorFactoryCreateFrameCryptor(
3133
const EncodableMap& constraints,

common/cpp/src/flutter_frame_cryptor.cc

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,8 @@ void FlutterFrameCryptorObserver::OnFrameCryptionStateChanged(
4848

4949
bool FlutterFrameCryptor::HandleFrameCryptorMethodCall(
5050
const MethodCallProxy& method_call,
51-
std::unique_ptr<MethodResultProxy> result) {
51+
std::unique_ptr<MethodResultProxy> result,
52+
std::unique_ptr<MethodResultProxy> *outResult) {
5253
const std::string& method_name = method_call.method_name();
5354
if (!method_call.arguments()) {
5455
result->Error("Bad Arguments", "Null arguments received");
@@ -102,7 +103,8 @@ bool FlutterFrameCryptor::HandleFrameCryptorMethodCall(
102103
KeyProviderDispose(params, std::move(result));
103104
return true;
104105
}
105-
106+
107+
*outResult = std::move(result);
106108
return false;
107109
}
108110

common/cpp/src/flutter_webrtc.cc

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1241,10 +1241,12 @@ void FlutterWebRTC::HandleMethodCall(
12411241
state[EncodableValue("state")] =
12421242
peerConnectionStateString(pc->peer_connection_state());
12431243
result->Success(EncodableValue(state));
1244-
} else if (HandleFrameCryptorMethodCall(method_call, std::move(result))) {
1245-
// Do nothing
12461244
} else {
1247-
result->NotImplemented();
1245+
if (HandleFrameCryptorMethodCall(method_call, std::move(result), &result)) {
1246+
return;
1247+
} else {
1248+
result->NotImplemented();
1249+
}
12481250
}
12491251
}
12501252

0 commit comments

Comments
 (0)
0