mirror of
https://github.com/RetroShare/libretroshare.git
synced 2026-09-14 11:05:45 +05:00
added async testing of friend server
This commit is contained in:
parent
2b79961df8
commit
5abd4043af
@ -201,8 +201,9 @@ bool FsClient::sendItem(const std::string& server_address,uint16_t server_port,
|
||||
|
||||
uint32_t ss;
|
||||
p.SendItem(item,ss);
|
||||
time_t now = time(nullptr);
|
||||
|
||||
while(true)
|
||||
while(now > time(nullptr)+15) // wait 15 secs for a response.
|
||||
{
|
||||
p.tick(); // ticks bio
|
||||
|
||||
|
||||
@ -36,8 +36,8 @@ void FriendServerManager::stopServer()
|
||||
RsTickingThread::askForStop() ;
|
||||
}
|
||||
}
|
||||
void FriendServerManager::checkServerAddress_async(const std::string& addr,uint16_t port, uint32_t timeout_ms,
|
||||
const std::function<void (const std::string& address,uint16_t port,bool result_status)>& callback)
|
||||
|
||||
bool FriendServerManager::checkServerAddress(const std::string& addr,uint16_t port, uint32_t timeout_ms)
|
||||
{
|
||||
uint16_t rs_tor_port;
|
||||
std::string rs_tor_addr;
|
||||
@ -45,7 +45,7 @@ void FriendServerManager::checkServerAddress_async(const std::string& addr,uint1
|
||||
|
||||
rsPeers->getProxyServer(RS_HIDDEN_TYPE_TOR,rs_tor_addr,rs_tor_port,flags);
|
||||
|
||||
callback(addr,port,FsClient::checkProxyConnection(addr,port,rs_tor_addr,rs_tor_port,timeout_ms));
|
||||
return FsClient::checkProxyConnection(addr,port,rs_tor_addr,rs_tor_port,timeout_ms);
|
||||
}
|
||||
|
||||
void FriendServerManager::setServerAddress(const std::string& addr,uint16_t port)
|
||||
|
||||
@ -26,8 +26,7 @@ public:
|
||||
virtual void startServer() override ;
|
||||
virtual void stopServer() override ;
|
||||
|
||||
virtual void checkServerAddress_async(const std::string& addr, uint16_t, uint32_t timeout_ms,
|
||||
const std::function<void (const std::string& address,uint16_t port,bool result_status)>& callback) override ;
|
||||
virtual bool checkServerAddress(const std::string& addr,uint16_t port, uint32_t timeout_ms) override;
|
||||
|
||||
virtual void setProfilePassphrase(const std::string& passphrase) override { mCachedPGPPassphrase = passphrase; }
|
||||
virtual void setServerAddress(const std::string&,uint16_t) override ;
|
||||
|
||||
@ -27,16 +27,10 @@ public:
|
||||
virtual void stopServer() =0;
|
||||
|
||||
// Testing system. Since the test can take some time (contacting the proxy, setting the connection,
|
||||
// getting some ack from the server), the whole test is asynchronous. The callback will be used to
|
||||
// return the result of the test, recalling the tested address and port.
|
||||
// getting some ack from the server). The whole test is synchronous and might be blocking for a while.
|
||||
// Consequently, the client needs to take care to avoid blocking e.g. the UI when calling this.
|
||||
//
|
||||
virtual void checkServerAddress_async(const std::string& addr,
|
||||
uint16_t port,
|
||||
uint32_t timeout_ms,
|
||||
const std::function<void (const std::string& address,
|
||||
uint16_t port,
|
||||
bool result_status)>& callback
|
||||
) =0;
|
||||
virtual bool checkServerAddress(const std::string& addr,uint16_t port, uint32_t timeout_ms) =0;
|
||||
|
||||
virtual void setServerAddress(const std::string&,uint16_t) =0;
|
||||
virtual void setFriendsToRequest(uint32_t) =0;
|
||||
|
||||
Loading…
Reference in New Issue
Block a user