43 lines
1016 B
C++
43 lines
1016 B
C++
#pragma once
|
|
|
|
#include "Lockable.h"
|
|
#include "IListenerInterface.h"
|
|
|
|
#include <cstdint>
|
|
#include <memory>
|
|
#include <vector>
|
|
|
|
namespace Feather::Network
|
|
{
|
|
class TCPSocket;
|
|
class TCPListenerClient;
|
|
|
|
class TCPClient
|
|
{
|
|
public:
|
|
TCPClient(std::unique_ptr<TCPListenerClient>&& client);
|
|
TCPClient(TCPClient&& client);
|
|
~TCPClient();
|
|
|
|
const LockableVector<uint8_t>& GetData() const;
|
|
|
|
private:
|
|
std::unique_ptr<TCPListenerClient> m_client;
|
|
};
|
|
// TODO: Can we eliminate the move constructor + overloads?
|
|
// Kinda unclean.
|
|
inline bool operator==(const TCPClient& a, const TCPClient& b) { return &a == &b; }
|
|
inline bool operator!=(const TCPClient& a, const TCPClient& b) { return &a != &b; }
|
|
|
|
class TCPListener
|
|
{
|
|
public:
|
|
TCPListener(uint16_t port, IListenerInterface* callbacks);
|
|
~TCPListener();
|
|
private:
|
|
IListenerInterface* m_callbacks;
|
|
std::unique_ptr<TCPSocket> m_socket;
|
|
};
|
|
|
|
|
|
} |