diff --git a/native/cpp/CommonCpp/NativeModules/InternalModules/NetworkModule.cpp b/native/cpp/CommonCpp/NativeModules/InternalModules/NetworkModule.cpp index 4167914a0..25f843530 100644 --- a/native/cpp/CommonCpp/NativeModules/InternalModules/NetworkModule.cpp +++ b/native/cpp/CommonCpp/NativeModules/InternalModules/NetworkModule.cpp @@ -1,25 +1,29 @@ #include "NetworkModule.h" #include "Logger.h" namespace comm { void NetworkModule::initializeNetworkModule( const std::string &userId, const std::string &deviceToken, const std::string &hostname) { std::string host = (hostname.size() == 0) ? "localhost" : hostname; // initialize network module // this is going to differ depending on a device // 10.0.2.2 for android emulator // 192.168.x.x for a physical device etc const std::shared_ptr credentials = (host.substr(0, 5) == "https") ? grpc::SslCredentials(grpc::SslCredentialsOptions()) : grpc::InsecureChannelCredentials(); this->networkClient.reset( new network::Client(host, "50051", credentials, userId, deviceToken)); } void NetworkModule::sendPong() { Logger::log("Sending PONG"); } + +void NetworkModule::close() { + networkClient.reset(); +} } // namespace comm diff --git a/native/cpp/CommonCpp/NativeModules/InternalModules/NetworkModule.h b/native/cpp/CommonCpp/NativeModules/InternalModules/NetworkModule.h index b39f5e5e5..6ca646489 100644 --- a/native/cpp/CommonCpp/NativeModules/InternalModules/NetworkModule.h +++ b/native/cpp/CommonCpp/NativeModules/InternalModules/NetworkModule.h @@ -1,18 +1,19 @@ #pragma once #include "../../grpc/Client.h" #include #include namespace comm { class NetworkModule { std::unique_ptr networkClient; public: void initializeNetworkModule( const std::string &userId, const std::string &deviceToken, const std::string &hostname = ""); void sendPong(); + void close(); }; } // namespace comm