add client

This commit is contained in:
2025-08-08 13:24:50 +02:00
parent b09c7f9efd
commit ac3e949323
14 changed files with 306 additions and 33 deletions

View File

@@ -1,23 +1,34 @@
#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::shared_ptr<client::FakeSocket>>> m_Clients;
public:
FakeSocket() {}
~FakeSocket() {}
utils::Signal<PeerID, const protocol::PacketBase&> OnSendToFakePeer;
void ConnectFakePeer(PeerID a_Peer);
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