// Copyright (c) 2022 NetEase, Inc. All rights reserved. // Use of this source code is governed by a MIT license that can be // found in the LICENSE file. #include "MethodCallHandlerImpl.h" #include #include #include #include #include "NimCore.h" MethodCallHandlerImpl::MethodCallHandlerImpl() {} void MethodCallHandlerImpl::onMethodCall( const flutter::MethodCall &method_call, std::shared_ptr > result) { const auto *arguments = std::get_if(method_call.arguments()); if (arguments) { NimCore::getInstance()->onMethodCall(method_call.method_name(), arguments, result); } else { if (result) { result->NotImplemented(); } } } flutter::MethodChannel * MethodCallHandlerImpl::startListening(flutter::PluginRegistrar *registrar) { m_methodChannel = std::make_unique < flutter::MethodChannel < flutter::EncodableValue >> ( registrar->messenger(), "flutter_openim_sdk", &flutter::StandardMethodCodec::GetInstance()); NimCore::getInstance()->setMethodChannel(m_methodChannel.get()); return m_methodChannel.get(); } void MethodCallHandlerImpl::stopListening() { NimCore::getInstance()->setMethodChannel(nullptr); }