diff options
Diffstat (limited to 'include/sibs')
-rw-r--r-- | include/sibs/DirectConnection.hpp | 13 |
1 files changed, 10 insertions, 3 deletions
diff --git a/include/sibs/DirectConnection.hpp b/include/sibs/DirectConnection.hpp index 9be55f1..2137fd2 100644 --- a/include/sibs/DirectConnection.hpp +++ b/include/sibs/DirectConnection.hpp @@ -13,6 +13,7 @@ #include "../utils.hpp" #include "Socket.hpp" #include "Message.hpp" +#include <future> namespace sibs { @@ -29,6 +30,13 @@ namespace sibs }; struct DirectConnectionPeer; + + struct PubSubConnectResult + { + std::shared_ptr<DirectConnectionPeer> peer; + PubSubResult result; + std::string resultStr; + }; using PubSubConnectCallback = std::function<void(std::shared_ptr<DirectConnectionPeer> peer, PubSubResult result, const std::string &resultStr)>; using PubSubReceiveDataCallback = std::function<void(std::shared_ptr<DirectConnectionPeer> peer, MessageType messageType, const void *data, const usize size)>; @@ -65,8 +73,6 @@ namespace sibs bool removePeer(int peerSocket); std::vector<std::shared_ptr<DirectConnectionPeer>> getPeers(); - - std::shared_ptr<DirectConnectionPeer> getPeerByAddress(const Ipv4 &address) const; protected: std::unique_ptr<Socket> createSocket(const Ipv4 &addressToBind, bool rendezvous, bool reuseAddr, bool bind = true); private: @@ -82,7 +88,8 @@ namespace sibs std::mutex peersMutex; bool alive; PubSubOnRemoveDisconnectedPeerCallback removeDisconnectedPeerCallback; - Ipv4Map<std::shared_ptr<DirectConnectionPeer>> peerByAddressMap; + Ipv4Map<std::shared_future<PubSubConnectResult>> connectionResults; + std::mutex connectionResultsMutex; }; struct DirectConnectionsUtils |