From 1167a78fd14b8a4a421378c8815a4992e06d11cd Mon Sep 17 00:00:00 2001 From: dec05eba Date: Fri, 23 Nov 2018 15:44:08 +0100 Subject: Add data routing for failed p2p connections --- include/sibs/DirectConnection.hpp | 1 + include/sibs/IpAddress.hpp | 2 ++ include/sibs/Message.hpp | 12 ++++++------ 3 files changed, 9 insertions(+), 6 deletions(-) (limited to 'include') diff --git a/include/sibs/DirectConnection.hpp b/include/sibs/DirectConnection.hpp index eb44153..70eaf4f 100644 --- a/include/sibs/DirectConnection.hpp +++ b/include/sibs/DirectConnection.hpp @@ -56,6 +56,7 @@ namespace sibs PubSubReceiveDataCallback receiveDataCallbackFunc; int sharedKeys = 0; PeerType type = PeerType::CLIENT; + bool routed = false; bool operator == (const DirectConnectionPeer &other) const; bool operator != (const DirectConnectionPeer &other) const; diff --git a/include/sibs/IpAddress.hpp b/include/sibs/IpAddress.hpp index 54cb58a..ea2a7bd 100644 --- a/include/sibs/IpAddress.hpp +++ b/include/sibs/IpAddress.hpp @@ -4,6 +4,7 @@ #include #include #include "../env.hpp" +#include "../types.hpp" #if OS_FAMILY != OS_FAMILY_WINDOWS #include #include @@ -32,6 +33,7 @@ namespace sibs // If @ip is nullptr, then bind to all available sockets (typical for servers) // Throws InvalidAddressException on error. Ipv4(const char *ip, unsigned short port); + Ipv4(u16 family, u32 address, u16 port); Ipv4(const Ipv4 &other); Ipv4& operator = (const Ipv4 &other); diff --git a/include/sibs/Message.hpp b/include/sibs/Message.hpp index b6eb858..4591221 100644 --- a/include/sibs/Message.hpp +++ b/include/sibs/Message.hpp @@ -1,7 +1,7 @@ #pragma once #include "../types.hpp" -#include +#include namespace sibs { @@ -20,11 +20,11 @@ namespace sibs void append(const void *data, const usize size); - usize getDataSize() const { return rawData.size() - 1; } - usize getRawSize() const { return rawData.size(); } + usize getDataSize() const { return serializer.getSize() - 1; } + usize getRawSize() const { return serializer.getSize(); } - const u8* data() const { return rawData.data(); } - private: - std::vector rawData; + const u8* data() { return serializer.getBuffer().data(); } + + sibs::SafeSerializer serializer; }; } \ No newline at end of file -- cgit v1.2.3