LivoxProto1: invoke enablePcloudDataReq
Sadly we don't get to immediately see the results of our work because we have to do a unified dispatcher for the incoming UDP messages on the command channel.
This commit is contained in:
@@ -155,28 +155,33 @@ public:
|
||||
bool success, const std::string& ipAddr, int fd
|
||||
)
|
||||
{
|
||||
if (success)
|
||||
// Fail early - if handshake failed, try next method
|
||||
if (!success)
|
||||
{
|
||||
// Store the IP address in the device
|
||||
context->device.discoveredDevice.ipAddr = ipAddr;
|
||||
// Store the handshake FD for heartbeats
|
||||
context->device.heartbeatFd = fd;
|
||||
context->device.startHeartbeat();
|
||||
context->callOriginalCb(true);
|
||||
if (OptionParser::getOptions().verbose)
|
||||
{
|
||||
std::cout << __func__ << ": Trying to connect to device by "
|
||||
<< "identifier" << "\n";
|
||||
}
|
||||
|
||||
// Try direct connect by device identifier
|
||||
context->device.connectByDeviceIdentifierReq(
|
||||
{context, std::bind(&ConnectReq::connectReq2,
|
||||
context.get(), context,
|
||||
std::placeholders::_1, std::placeholders::_2,
|
||||
std::placeholders::_3)});
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
if (OptionParser::getOptions().verbose)
|
||||
{
|
||||
std::cout << __func__ << ": Trying to connect to device by "
|
||||
<< "identifier" << "\n";
|
||||
}
|
||||
// Success - store connection info and proceed to next step
|
||||
context->device.discoveredDevice.ipAddr = ipAddr;
|
||||
context->device.heartbeatFd = fd;
|
||||
context->device.startHeartbeat();
|
||||
|
||||
// Try direct connect by device identifier
|
||||
context->device.connectByDeviceIdentifierReq(
|
||||
{context, std::bind(&ConnectReq::connectReq2, context.get(), context,
|
||||
std::placeholders::_1, std::placeholders::_2,
|
||||
std::placeholders::_3)});
|
||||
context->device.enablePcloudDataReq(
|
||||
{context, std::bind(&ConnectReq::connectReq3, context.get(), context,
|
||||
std::placeholders::_1)});
|
||||
}
|
||||
|
||||
void connectReq2(
|
||||
@@ -184,19 +189,29 @@ public:
|
||||
bool success, const std::string& ipAddr, int fd
|
||||
)
|
||||
{
|
||||
if (success)
|
||||
// Fail early - if this also failed, all connection attempts failed
|
||||
if (!success)
|
||||
{
|
||||
// Store the IP address in the device
|
||||
context->device.discoveredDevice.ipAddr = ipAddr;
|
||||
// Store the handshake FD for heartbeats
|
||||
context->device.heartbeatFd = fd;
|
||||
context->device.startHeartbeat();
|
||||
context->callOriginalCb(true);
|
||||
context->callOriginalCb(false);
|
||||
return;
|
||||
}
|
||||
|
||||
// All connection attempts failed
|
||||
context->callOriginalCb(false);
|
||||
// Success - store connection info and proceed to next step
|
||||
context->device.discoveredDevice.ipAddr = ipAddr;
|
||||
context->device.heartbeatFd = fd;
|
||||
context->device.startHeartbeat();
|
||||
|
||||
context->device.enablePcloudDataReq(
|
||||
{context, std::bind(&ConnectReq::connectReq3, context.get(), context,
|
||||
std::placeholders::_1)});
|
||||
}
|
||||
|
||||
void connectReq3(
|
||||
std::shared_ptr<ConnectReq> context,
|
||||
bool success
|
||||
)
|
||||
{
|
||||
context->callOriginalCb(success);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user