summaryrefslogtreecommitdiff
path: root/src/network/protocol.h
diff options
context:
space:
mode:
authorRoman Smrž <roman.smrz@seznam.cz>2023-08-27 10:37:20 +0200
committerRoman Smrž <roman.smrz@seznam.cz>2023-08-27 16:32:21 +0200
commita40f12cf820b3e11cc72f7b20046c8077ab0d0a5 (patch)
tree5086866402c923b3def3c55674dfa260926b564c /src/network/protocol.h
parent09c1e987f6ddfdefb26b6a5f359363303720d5fb (diff)
Network: identity announce and update in protocol object
Diffstat (limited to 'src/network/protocol.h')
-rw-r--r--src/network/protocol.h12
1 files changed, 8 insertions, 4 deletions
diff --git a/src/network/protocol.h b/src/network/protocol.h
index df29c05..51f8d59 100644
--- a/src/network/protocol.h
+++ b/src/network/protocol.h
@@ -25,7 +25,7 @@ class NetworkProtocol
{
public:
NetworkProtocol();
- explicit NetworkProtocol(int sock);
+ explicit NetworkProtocol(int sock, Identity self);
NetworkProtocol(const NetworkProtocol &) = delete;
NetworkProtocol(NetworkProtocol &&);
NetworkProtocol & operator=(const NetworkProtocol &) = delete;
@@ -55,18 +55,22 @@ public:
Connection connect(sockaddr_in6 addr);
- bool recvfrom(vector<uint8_t> & buffer, sockaddr_in6 & addr);
- void sendto(const vector<uint8_t> & buffer, sockaddr_in addr);
- void sendto(const vector<uint8_t> & buffer, sockaddr_in6 addr);
+ void updateIdentity(Identity self);
+ void announceTo(variant<sockaddr_in, sockaddr_in6> addr);
void shutdown();
private:
+ bool recvfrom(vector<uint8_t> & buffer, sockaddr_in6 & addr);
+ void sendto(const vector<uint8_t> & buffer, variant<sockaddr_in, sockaddr_in6> addr);
+
int sock;
mutex protocolMutex;
vector<uint8_t> buffer;
+ optional<Identity> self;
+
struct ConnectionPriv;
vector<ConnectionPriv *> connections;
};