aboutsummaryrefslogtreecommitdiff
path: root/include
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 /include
parentd20d7198f562bef49a6f0e74cd4a6c71fe71c1fc (diff)
Remove server node from getPeers func
Diffstat (limited to 'include')
-rw-r--r--include/sibs/DirectConnection.hpp9
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);