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 /include | |
parent | a684368d5545488602a29fa2122a22398f650f7f (diff) |
Remove server node from getPeers func
Diffstat (limited to 'include')
-rw-r--r-- | include/sibs/DirectConnection.hpp | 9 |
1 files changed, 8 insertions, 1 deletions
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<void(std::shared_ptr<DirectConnectionPeer> peer, MessageType messageType, const void *data, const usize size)>; using PubSubSendDataCallback = std::function<void(PubSubResult result, const std::string &resultStr)>; using PubSubOnRemoveDisconnectedPeerCallback = std::function<void(std::shared_ptr<DirectConnectionPeer> 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<Socket> 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); |