From 402a3fce0552abffe2ab2808b9657cd73885771f Mon Sep 17 00:00:00 2001 From: dec05eba Date: Sun, 4 Nov 2018 04:51:46 +0100 Subject: Remove server node from getPeers func --- include/sibs/DirectConnection.hpp | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) (limited to 'include') diff --git a/include/sibs/DirectConnection.hpp b/include/sibs/DirectConnection.hpp index d96890b..eb44153 100644 --- a/include/sibs/DirectConnection.hpp +++ b/include/sibs/DirectConnection.hpp @@ -42,6 +42,12 @@ namespace sibs using PubSubReceiveDataCallback = std::function peer, MessageType messageType, const void *data, const usize size)>; using PubSubSendDataCallback = std::function; using PubSubOnRemoveDisconnectedPeerCallback = std::function peer)>; + + enum class PeerType + { + SERVER, + CLIENT + }; struct DirectConnectionPeer { @@ -49,6 +55,7 @@ namespace sibs Ipv4 address; PubSubReceiveDataCallback receiveDataCallbackFunc; int sharedKeys = 0; + PeerType type = PeerType::CLIENT; bool operator == (const DirectConnectionPeer &other) const; bool operator != (const DirectConnectionPeer &other) const; @@ -76,7 +83,7 @@ namespace sibs protected: std::unique_ptr createSocket(const Ipv4 &addressToBind, bool rendezvous, bool reuseAddr, bool bind = true); private: - void connect(const Ipv4 &address, bool rendezvous, bool reuseAddr, PubSubConnectCallback connectCallbackFunc, PubSubReceiveDataCallback receiveDataCallbackFunc, bool bind); + void connect(const Ipv4 &address, bool rendezvous, bool reuseAddr, PubSubConnectCallback connectCallbackFunc, PubSubReceiveDataCallback receiveDataCallbackFunc, bool bind, bool server); void removeDisconnectedPeers(); void receiveData(); int receiveDataFromPeer(const int socket, char *output, usize *receivedTotalSize); -- cgit v1.2.3