INetwork interface defines the essential methods for network communication within the game. It serves as a blueprint for implementing network functionality, allowing for broadcasting messages and running the server.The INetwork interface is crucial for enabling real-time communication between the server and clients, providing methods for broadcasting data and managing the server lifecycle.
namespace ecs {
class IContext;
class INetwork {
public:
virtual ~INetwork() = default;
virtual void broadcast(const IPacket &packet) = 0;
virtual int run(std::shared_ptr<IContext> &) = 0;
protected:
private:
};
} // namespace ecs
virtual ~INetwork() = default;
Virtual destructor to ensure proper cleanup of derived classes.
virtual void broadcast(const IPacket &packet) = 0;
Broadcasts the given packet to all currently connected clients.
const IPacket &packet: A reference to the packet to be sent to all connected clients.virtual int run(std::shared_ptr<IContext> &) = 0;
Runs the server.
std::shared_ptr<IContext> &: A shared pointer to the game context, allowing access to game state and entities.EXIT_SUCCESS for now.