refactor IServerSocket
This commit is contained in:
@@ -13,7 +13,7 @@ class IServerSocket {
|
||||
utils::Signal<PlayerID> OnDisconnect;
|
||||
utils::Signal<PlayerID, const protocol::PacketBase&> OnReceive;
|
||||
|
||||
virtual void Send(PlayerID, const protocol::PacketBase&) = 0;
|
||||
void Send(PlayerID a_PlayerId, const protocol::PacketBase& a_Packet);
|
||||
|
||||
IServerSocket() {}
|
||||
virtual ~IServerSocket() {}
|
||||
@@ -25,6 +25,7 @@ class IServerSocket {
|
||||
void OnConnectPeer(PeerID a_PeerId);
|
||||
void OnDisconnectPeer(PeerID a_PeerId);
|
||||
void OnReceivePeer(PeerID a_PeerId, const protocol::PacketBase& a_Packet);
|
||||
virtual void SendPeer(PeerID a_PeerId, const protocol::PacketBase& a_Packet) = 0;
|
||||
};
|
||||
|
||||
} // namespace server
|
||||
|
||||
20
include/server/socket/FakeSocket.h
Normal file
20
include/server/socket/FakeSocket.h
Normal file
@@ -0,0 +1,20 @@
|
||||
#pragma once
|
||||
|
||||
#include <server/IServerSocket.h>
|
||||
|
||||
namespace td {
|
||||
namespace server {
|
||||
|
||||
class FakeSocket : public IServerSocket {
|
||||
public:
|
||||
FakeSocket() {}
|
||||
~FakeSocket() {}
|
||||
|
||||
utils::Signal<PeerID, const protocol::PacketBase&> OnSend;
|
||||
|
||||
protected:
|
||||
virtual void SendPeer(PeerID a_Peer, const protocol::PacketBase& a_Packet) override;
|
||||
};
|
||||
|
||||
} // namespace server
|
||||
} // namespace td
|
||||
@@ -1,19 +0,0 @@
|
||||
#pragma once
|
||||
|
||||
#include <server/IServerSocket.h>
|
||||
|
||||
namespace td {
|
||||
namespace server {
|
||||
|
||||
class TcpSocket : public IServerSocket {
|
||||
private:
|
||||
/* data */
|
||||
public:
|
||||
TcpSocket(/* args */) {}
|
||||
~TcpSocket() {}
|
||||
|
||||
virtual void Send(PlayerID, const protocol::PacketBase&) {}
|
||||
};
|
||||
|
||||
} // namespace server
|
||||
} // namespace td
|
||||
Reference in New Issue
Block a user