Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Files
F3521868
D3101.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
3 KB
Referenced Files
None
Subscribers
None
D3101.diff
View Options
diff --git a/native/cpp/CommonCpp/NativeModules/InternalModules/NetworkModule.h b/native/cpp/CommonCpp/NativeModules/InternalModules/NetworkModule.h
--- a/native/cpp/CommonCpp/NativeModules/InternalModules/NetworkModule.h
+++ b/native/cpp/CommonCpp/NativeModules/InternalModules/NetworkModule.h
@@ -8,7 +8,6 @@
namespace comm {
class NetworkModule {
std::unique_ptr<network::Client> networkClient;
- std::function<void(SocketStatus)> setReadyState;
public:
void initializeNetworkModule(
diff --git a/native/cpp/CommonCpp/NativeModules/InternalModules/NetworkModule.cpp b/native/cpp/CommonCpp/NativeModules/InternalModules/NetworkModule.cpp
--- a/native/cpp/CommonCpp/NativeModules/InternalModules/NetworkModule.cpp
+++ b/native/cpp/CommonCpp/NativeModules/InternalModules/NetworkModule.cpp
@@ -77,7 +77,10 @@
void NetworkModule::assignSetReadyStateCallback(
std::function<void(SocketStatus)> callback) {
- this->setReadyState = callback;
+ if (!this->networkClient) {
+ return;
+ }
+ this->networkClient->assignSetReadyStateCallback(callback);
}
} // namespace comm
diff --git a/native/cpp/CommonCpp/grpc/Client.h b/native/cpp/CommonCpp/grpc/Client.h
--- a/native/cpp/CommonCpp/grpc/Client.h
+++ b/native/cpp/CommonCpp/grpc/Client.h
@@ -45,6 +45,7 @@
void setOnOpenCallback(std::function<void()> callback);
void setOnCloseCallback(std::function<void()> callback);
void closeGetStream();
+ void assignSetReadyStateCallback(std::function<void(SocketStatus)> callback);
};
} // namespace network
diff --git a/native/cpp/CommonCpp/grpc/Client.cpp b/native/cpp/CommonCpp/grpc/Client.cpp
--- a/native/cpp/CommonCpp/grpc/Client.cpp
+++ b/native/cpp/CommonCpp/grpc/Client.cpp
@@ -119,5 +119,13 @@
this->clientGetReadReactor->close();
}
+void Client::assignSetReadyStateCallback(
+ std::function<void(SocketStatus)> callback) {
+ if (!this->clientGetReadReactor) {
+ return;
+ }
+ this->clientGetReadReactor->assignSetReadyStateCallback(callback);
+}
+
} // namespace network
} // namespace comm
diff --git a/native/cpp/CommonCpp/grpc/ClientGetReadReactor.h b/native/cpp/CommonCpp/grpc/ClientGetReadReactor.h
--- a/native/cpp/CommonCpp/grpc/ClientGetReadReactor.h
+++ b/native/cpp/CommonCpp/grpc/ClientGetReadReactor.h
@@ -1,5 +1,6 @@
#pragma once
+#include "../NativeModules/InternalModules/SocketStatus.h"
#include <grpcpp/grpcpp.h>
#include "_generated/tunnelbroker.grpc.pb.h"
@@ -14,9 +15,11 @@
std::mutex onReadDoneCallbackMutex;
std::mutex onOpenCallbackMutex;
std::mutex onCloseCallbackMutex;
+ std::mutex setReadyStateMutex;
std::function<void(std::string)> onReadDoneCallback;
std::function<void()> onOpenCallback;
std::function<void()> onCloseCallback;
+ std::function<void(SocketStatus)> setReadyState;
public:
ClientGetReadReactor(
@@ -30,4 +33,5 @@
void
setOnReadDoneCallback(std::function<void(std::string)> onReadDoneCallback);
void setOnCloseCallback(std::function<void()> onCloseCallback);
+ void assignSetReadyStateCallback(std::function<void(SocketStatus)> callback);
};
diff --git a/native/cpp/CommonCpp/grpc/ClientGetReadReactor.cpp b/native/cpp/CommonCpp/grpc/ClientGetReadReactor.cpp
--- a/native/cpp/CommonCpp/grpc/ClientGetReadReactor.cpp
+++ b/native/cpp/CommonCpp/grpc/ClientGetReadReactor.cpp
@@ -42,3 +42,9 @@
std::lock_guard<std::mutex> guard{this->onCloseCallbackMutex};
this->onCloseCallback = onCloseCallback;
}
+
+void ClientGetReadReactor::assignSetReadyStateCallback(
+ std::function<void(SocketStatus)> callback) {
+ std::lock_guard<std::mutex> guard{this->setReadyStateMutex};
+ this->setReadyState = callback;
+}
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Tue, Dec 24, 5:16 AM (20 h, 28 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
2698414
Default Alt Text
D3101.diff (3 KB)
Attached To
Mode
D3101: [CommCoreModule] Pass `setReadyState` callback to `ClientGetReadReactor`
Attached
Detach File
Event Timeline
Log In to Comment