36 lines
788 B
C++
36 lines
788 B
C++
#pragma once
|
|
|
|
#include <client/socket/FakeSocket.h>
|
|
#include <optional>
|
|
#include <server/IServerSocket.h>
|
|
|
|
namespace td {
|
|
namespace server {
|
|
|
|
class FakeSocket : public IServerSocket {
|
|
private:
|
|
std::vector<std::optional<std::weak_ptr<client::FakeSocket>>> m_Clients;
|
|
|
|
public:
|
|
FakeSocket() {}
|
|
~FakeSocket() {}
|
|
|
|
PeerID ConnectFakePeer(const std::shared_ptr<client::FakeSocket>& a_Socket);
|
|
void DisconnectFakePeer(PeerID a_Peer);
|
|
void ReceiveFromFakePeer(PeerID a_Peer, const protocol::PacketBase& a_Packet);
|
|
|
|
protected:
|
|
virtual void SendPeer(PeerID a_Peer, const protocol::PacketBase& a_Packet) override;
|
|
|
|
private:
|
|
/**
|
|
* \return -1 if all previous ids are not free
|
|
*/
|
|
int GetNextFreeId();
|
|
|
|
friend class client::FakeSocket;
|
|
};
|
|
|
|
} // namespace server
|
|
} // namespace td
|