mirror of
https://github.com/alterware/master-server.git
synced 2026-03-13 04:03:03 +00:00
init
This commit is contained in:
56
src/service.hpp
Normal file
56
src/service.hpp
Normal file
@@ -0,0 +1,56 @@
|
||||
#pragma once
|
||||
|
||||
#include "network/address.hpp"
|
||||
|
||||
class server;
|
||||
|
||||
class service
|
||||
{
|
||||
public:
|
||||
class execution_exception : public std::runtime_error
|
||||
{
|
||||
public:
|
||||
using std::runtime_error::runtime_error;
|
||||
};
|
||||
|
||||
service(server& server)
|
||||
: server_(server)
|
||||
{
|
||||
}
|
||||
|
||||
virtual ~service() = default;
|
||||
|
||||
service(service&&) = delete;
|
||||
service(const service&) = delete;
|
||||
service& operator=(service&&) = delete;
|
||||
service& operator=(const service&) = delete;
|
||||
|
||||
[[nodiscard]] virtual const char* get_command() const { return nullptr; }
|
||||
|
||||
virtual void handle_command([[maybe_unused]] const network::address& target,
|
||||
[[maybe_unused]] const std::string_view& data)
|
||||
{
|
||||
}
|
||||
|
||||
virtual void run_frame()
|
||||
{
|
||||
}
|
||||
|
||||
protected:
|
||||
[[nodiscard]] const server& get_server() const
|
||||
{
|
||||
return server_;
|
||||
}
|
||||
|
||||
server& get_server()
|
||||
{
|
||||
return server_;
|
||||
}
|
||||
|
||||
private:
|
||||
server& server_;
|
||||
};
|
||||
|
||||
// server and service have a cycle, but fuck, it's easier that way
|
||||
// include guards should handle that
|
||||
#include "server.hpp"
|
||||
Reference in New Issue
Block a user