14 _game =
new Registry(_dispatcher, _queue);
32 std::forward_list<std::string> serializedMessages;
33 for (
const auto& event : _eventsFromGame) {
34 std::ostringstream oss;
36 serializedMessages.push_front(oss.str());
38 _eventsFromGame.clear();
39 return serializedMessages;
44 _eventsFromGame.push_front(event);
49 std::forward_list<std::string> serializedMessages;
50 for (
const auto& event : _game->
sync_game()) {
51 std::ostringstream oss;
53 serializedMessages.push_front(oss.str());
55 return serializedMessages;
60 std::istringstream iss(event);
62 _eventsFromServer.push_front(loadedMessage);
63 _queue->
push(loadedMessage);
GameMessage deserialize(std::istringstream &is)
Deserializes a GameMessage object from a binary stream.
void serialize(const GameMessage &message, std::ostringstream &os)
Serializes a GameMessage object into a binary stream.
A utility class for dispatching and handling game events.
void subscribe(Callback callback)
Subscribes a listener to game events.
std::forward_list< std::string > getGameEvents(void)
Retrieves game messages.
void onGameEventReceived(const GameMessage &event)
Handles an event received during gameplay.
void update(float _deltaTime)
Updates the game state for the current frame.
Game()
Constructs a new Game object.
std::forward_list< std::string > getCurrentGameState(void)
Gets the current game state (syncing)
~Game()
Destroys the Game object.
void onServerEventReceived(std::string &event)
Handles an event received from server.
A thread-safe queue for storing and managing GameMessage objects.
void push(const GameMessage &item)
Push a GameMessage item into the queue.
Manages entities and their associated components, enabling the creation, deletion,...
void run_systems()
Executes all registered systems.
std::vector< GameMessage > sync_game()
Creates a list of GameMessages that syncs the player to the game.
float deltaTime
The time difference between the current frame and the last frame.
A structure representing a game message.