aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorAleksi Lindeman <dec05eba@protonmail.com>2018-11-04 04:51:46 +0100
committerAleksi Lindeman <dec05eba@protonmail.com>2018-11-04 04:51:46 +0100
commit11ee593a8387cf2ca0bcdbaf0d39ad69bee6dec4 (patch)
treeb86d319919df892930a26eff136334a78ec14731 /src
parentd20d7198f562bef49a6f0e74cd4a6c71fe71c1fc (diff)
Remove server node from getPeers func
Diffstat (limited to 'src')
-rw-r--r--src/DirectConnection.cpp12
1 files changed, 7 insertions, 5 deletions
diff --git a/src/DirectConnection.cpp b/src/DirectConnection.cpp
index b548a02..a00eeea 100644
--- a/src/DirectConnection.cpp
+++ b/src/DirectConnection.cpp
@@ -102,12 +102,12 @@ namespace sibs
void DirectConnections::connectServer(const Ipv4 &address, PubSubConnectCallback connectCallbackFunc, PubSubReceiveDataCallback receiveDataCallbackFunc)
{
- connect(address, false, true, connectCallbackFunc, receiveDataCallbackFunc, true);
+ connect(address, false, true, connectCallbackFunc, receiveDataCallbackFunc, true, true);
}
void DirectConnections::connect(const Ipv4 &address, PubSubConnectCallback connectCallbackFunc, PubSubReceiveDataCallback receiveDataCallbackFunc)
{
- connect(address, true, true, connectCallbackFunc, receiveDataCallbackFunc, true);
+ connect(address, true, true, connectCallbackFunc, receiveDataCallbackFunc, true, false);
}
static bool isReady(const std::shared_future<PubSubConnectResult> &connectionResultFuture)
@@ -115,7 +115,7 @@ namespace sibs
return connectionResultFuture.wait_for(std::chrono::seconds(0)) == std::future_status::ready;
}
- void DirectConnections::connect(const Ipv4 &address, bool rendezvous, bool reuseAddr, PubSubConnectCallback connectCallbackFunc, PubSubReceiveDataCallback receiveDataCallbackFunc, bool bind)
+ void DirectConnections::connect(const Ipv4 &address, bool rendezvous, bool reuseAddr, PubSubConnectCallback connectCallbackFunc, PubSubReceiveDataCallback receiveDataCallbackFunc, bool bind, bool server)
{
connectionResultsMutex.lock();
auto it = connectionResults.find(address);
@@ -141,7 +141,7 @@ namespace sibs
}
else
{
- connectionResults[address] = std::async(std::launch::async, [this, address, rendezvous, reuseAddr, connectCallbackFunc, receiveDataCallbackFunc, bind]()
+ connectionResults[address] = std::async(std::launch::async, [this, address, rendezvous, reuseAddr, connectCallbackFunc, receiveDataCallbackFunc, bind, server]()
{
std::shared_ptr<DirectConnectionPeer> peer = std::make_shared<DirectConnectionPeer>();
std::unique_ptr<Socket> socket;
@@ -172,6 +172,7 @@ namespace sibs
peer->socket = std::move(socket);
peer->address = address;
peer->receiveDataCallbackFunc = receiveDataCallbackFunc;
+ peer->type = (server ? PeerType::SERVER : PeerType::CLIENT);
peersMutex.unlock();
if(connectCallbackFunc)
@@ -240,7 +241,8 @@ namespace sibs
std::lock_guard<std::mutex> lock(peersMutex);
for(auto &it : peers)
{
- result.push_back(it.second);
+ if(it.second->type == PeerType::CLIENT)
+ result.push_back(it.second);
}
return result;
}