Cogs.Core
ConnectionHub.h
1#pragma once
2
3#if !defined( EMSCRIPTEN )
4
5#include "Connection.h"
6#include "MessageHub.h"
7
8namespace Cogs {
9 namespace Network {
17 class COGSFOUNDATION_API ConnectionHub : public ConnectionTCP, public MessageHub {
18 public:
19 ConnectionHub(uint32_t id) : MessageHub(id) {}
20 ConnectionHub(Socket socket, const SockaddrIn& addr) : ConnectionTCP(socket, addr), MessageHub(0) {}
21
22 virtual bool processOutgoing() override;
23 virtual bool processIncoming() override;
24
25 protected:
26 virtual void handleReceivedMessage(const Message::Ptr& message);
27 virtual bool disconnect() override;
28
29 private:
30 struct Header {
31 uint32_t id = 0;
32 uint64_t size = 0;
33 };
34
35 Message::Ptr outgoingMessage;
36 uint64_t bytesSent = 0;
37
38 Message::Ptr incomingMessage;
39 Header incomingHeader;
40 };
41 }
42}
43
44#endif
A ConnectionHub combines a TCP connection with a MessageHub to enable the forwarding and receiving of...
Definition: ConnectionHub.h:17
A MessageHub connects to other hubs to form a simple peer-to-peer application-internal networking sys...
Definition: MessageHub.h:30
Contains all Cogs related functionality.
Definition: FieldSetter.h:23