mirror of
https://github.com/MaSzyna-EU07/maszyna.git
synced 2026-07-18 21:29:18 +02:00
work
This commit is contained in:
@@ -2,6 +2,11 @@
|
||||
#include "simulation.h"
|
||||
#include "network/backend/asio.h"
|
||||
|
||||
network::server_manager::server_manager()
|
||||
{
|
||||
backbuffer = std::make_shared<std::fstream>("backbuffer.bin", std::ios::out | std::ios::in | std::ios::trunc | std::ios::binary);
|
||||
}
|
||||
|
||||
command_queue::commands_map network::server_manager::pop_commands()
|
||||
{
|
||||
command_queue::commands_map map;
|
||||
@@ -14,13 +19,29 @@ command_queue::commands_map network::server_manager::pop_commands()
|
||||
|
||||
void network::server_manager::push_delta(double dt, double sync, const command_queue::commands_map &commands)
|
||||
{
|
||||
if (dt == 0.0 && commands.empty())
|
||||
return;
|
||||
|
||||
for (auto srv : servers)
|
||||
srv->push_delta(dt, sync, commands);
|
||||
|
||||
frame_info msg;
|
||||
msg.dt = dt;
|
||||
msg.sync = sync;
|
||||
msg.commands = commands;
|
||||
|
||||
serialize_message(msg, *backbuffer.get());
|
||||
}
|
||||
|
||||
void network::server_manager::update()
|
||||
{
|
||||
for (auto srv : servers)
|
||||
srv->update();
|
||||
}
|
||||
|
||||
void network::server_manager::create_server(asio::io_context &ctx, const std::string &host, uint32_t port)
|
||||
{
|
||||
servers.emplace_back(std::make_shared<tcp::server>(ctx, host, port));
|
||||
servers.emplace_back(std::make_shared<tcp::server>(backbuffer, ctx, host, port));
|
||||
}
|
||||
|
||||
network::manager::manager()
|
||||
@@ -30,6 +51,7 @@ network::manager::manager()
|
||||
void network::manager::poll()
|
||||
{
|
||||
io_context.poll();
|
||||
servers->update();
|
||||
}
|
||||
|
||||
void network::manager::create_server(const std::string &host, uint32_t port)
|
||||
|
||||
Reference in New Issue
Block a user