diff options
author | dec05eba <dec05eba@protonmail.com> | 2018-11-04 04:51:46 +0100 |
---|---|---|
committer | dec05eba <dec05eba@protonmail.com> | 2020-08-18 22:56:48 +0200 |
commit | 402a3fce0552abffe2ab2808b9657cd73885771f (patch) | |
tree | ecea63fc37db13343a2e7cd190f15ca2c2a08581 /src | |
parent | a684368d5545488602a29fa2122a22398f650f7f (diff) |
Remove server node from getPeers func
Diffstat (limited to 'src')
-rw-r--r-- | src/DirectConnection.cpp | 12 |
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; } |