add StateMachine
This commit is contained in:
@@ -1,30 +1,21 @@
|
||||
#pragma once
|
||||
|
||||
#include <memory>
|
||||
#include <server/IServerSocket.h>
|
||||
#include <server/IServerState.h>
|
||||
#include <chrono>
|
||||
#include <td/common/StateMachine.h>
|
||||
|
||||
namespace td {
|
||||
namespace server {
|
||||
|
||||
class Server {
|
||||
class ServerState;
|
||||
|
||||
class Server : public StateMachine<Server, void, float> {
|
||||
private:
|
||||
std::shared_ptr<IServerSocket> m_Socket;
|
||||
std::shared_ptr<IServerState> m_State;
|
||||
std::chrono::time_point<std::chrono::system_clock> m_LastTime;
|
||||
|
||||
public:
|
||||
Server(const std::shared_ptr<IServerSocket>& a_Socket) : m_Socket(a_Socket), m_LastTime(std::chrono::system_clock::now()) {}
|
||||
Server(const std::shared_ptr<IServerSocket>& a_Socket) : m_Socket(a_Socket) {}
|
||||
|
||||
void Update();
|
||||
|
||||
void UpdateState(const std::shared_ptr<IServerState>& a_State);
|
||||
|
||||
private:
|
||||
void Update(float a_Delta);
|
||||
|
||||
friend class IServerState;
|
||||
friend class ServerState;
|
||||
};
|
||||
|
||||
} // namespace server
|
||||
|
||||
Reference in New Issue
Block a user