16
0
mirror of https://github.com/MaSzyna-EU07/maszyna.git synced 2026-07-17 23:39:18 +02:00
This commit is contained in:
milek7
2019-01-20 15:31:48 +01:00
parent 84153aac80
commit 1ef74838ee
10 changed files with 55 additions and 48 deletions

0
network/backend/file.cpp Normal file
View File

22
network/backend/file.h Normal file
View File

@@ -0,0 +1,22 @@
#include "network/network.h"
namespace network::file
{
class server : public network::server
{
private:
std::fstream stream;
public:
server();
};
class client : public network::client
{
private:
std::fstream stream;
public:
client();
};
}

View File

@@ -113,11 +113,6 @@ command_queue::commands_map network::connection::pop_commands()
// server
network::server::server()
{
recorder.open("recorder.bin", std::ios::trunc | std::ios::out | std::ios::binary);
}
void network::server::push_delta(double dt, double sync, const command_queue::commands_map &commands)
{
if (dt == 0.0 && commands.empty())
@@ -128,12 +123,6 @@ void network::server::push_delta(double dt, double sync, const command_queue::co
msg.sync = sync;
msg.commands = commands;
sn_utils::ls_uint32(recorder, 0x37305545);
sn_utils::ls_uint32(recorder, 0);
sn_utils::ls_uint16(recorder, (uint16_t)msg.type);
msg.serialize(recorder);
recorder.flush();
for (auto c : clients)
if (c->state == connection::ACTIVE)
c->send_message(msg);

View File

@@ -54,12 +54,10 @@ namespace network
void handle_message(connection &conn, const message &msg);
std::vector<std::shared_ptr<connection>> clients;
std::fstream recorder;
command_queue::commands_map client_commands_queue;
public:
server();
void push_delta(double dt, double sync, const command_queue::commands_map &commands);
command_queue::commands_map pop_commands();
};