aboutsummaryrefslogtreecommitdiff
path: root/include/sibs/DirectConnection.hpp
diff options
context:
space:
mode:
Diffstat (limited to 'include/sibs/DirectConnection.hpp')
-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);