Manual disconnect on deallocation and do not clear message handler or message received
Summary: Trigger a manual disconnect on deallocation. This was done automatically for us when the underlying socket gets released. But, this gives a bit more visibility and control onto exactly when this is going to take place. Additionally, do not clear the message handler when a message is received. It is not required as sendExpectResponse is one time called only used for certificate exchange. If this takes place again, a new handler will be set anyway. Reviewed By: passy Differential Revision: D31231828 fbshipit-source-id: 36ad13564a358b88d1618e94195fe05433d80993
This commit is contained in:
committed by
Facebook GitHub Bot
parent
ef6e802244
commit
cf1d579462
@@ -92,22 +92,21 @@ class WebSocketSerializer : public FlipperPayloadSerializer {
|
||||
|
||||
FlipperWebSocket::FlipperWebSocket(
|
||||
FlipperConnectionEndpoint endpoint,
|
||||
std::unique_ptr<FlipperSocketBasePayload> payload,
|
||||
folly::EventBase* eventBase)
|
||||
: endpoint_(std::move(endpoint)),
|
||||
payload_(std::move(payload)),
|
||||
eventBase_(eventBase) {}
|
||||
std::unique_ptr<FlipperSocketBasePayload> payload)
|
||||
: endpoint_(std::move(endpoint)), payload_(std::move(payload)) {}
|
||||
|
||||
FlipperWebSocket::FlipperWebSocket(
|
||||
FlipperConnectionEndpoint endpoint,
|
||||
std::unique_ptr<FlipperSocketBasePayload> payload,
|
||||
folly::EventBase* eventBase,
|
||||
ConnectionContextStore* connectionContextStore)
|
||||
: endpoint_(std::move(endpoint)),
|
||||
payload_(std::move(payload)),
|
||||
eventBase_(eventBase),
|
||||
connectionContextStore_(connectionContextStore) {}
|
||||
|
||||
FlipperWebSocket::~FlipperWebSocket() {
|
||||
disconnect();
|
||||
}
|
||||
|
||||
void FlipperWebSocket::setEventHandler(SocketEventHandler eventHandler) {
|
||||
eventHandler_ = std::move(eventHandler);
|
||||
}
|
||||
@@ -169,8 +168,7 @@ bool FlipperWebSocket::connect(FlipperConnectionManager* manager) {
|
||||
promise.set_value(false);
|
||||
}
|
||||
}
|
||||
eventBase_->runInEventBaseThread(
|
||||
[eventHandler, event]() { eventHandler(event); });
|
||||
eventHandler(event);
|
||||
};
|
||||
socket_.messageHandler = ^(const std::string& message) {
|
||||
this->messageHandler_(message);
|
||||
@@ -240,7 +238,6 @@ void FlipperWebSocket::sendExpectResponse(
|
||||
|
||||
[socket_ setMessageHandler:^(const std::string& msg) {
|
||||
completion(msg, false);
|
||||
[socket_ setMessageHandler:NULL];
|
||||
}];
|
||||
NSError* error = NULL;
|
||||
[socket_ send:messageObjc error:&error];
|
||||
|
||||
Reference in New Issue
Block a user