More work on client and server

This commit is contained in:
2021-11-11 13:56:49 -05:00
parent 051e6bc8bf
commit caa5bab9d3
6 changed files with 314 additions and 199 deletions

View File

@@ -5,6 +5,7 @@
#include "luaconsole.hpp"
#include "invocation.hpp"
#include "util.hpp"
#include "printbuffer.hpp"
#include <memory>
class LpxClient : public DrivenEngine {
@@ -15,6 +16,7 @@ public:
InvocationQueue unack_;
UniqueChannel channel_;
LuaConsole console_;
PrintChanneler print_channeler_;
Gui gui_;
int64_t gui_place_;
@@ -186,6 +188,11 @@ public:
}
}
void change_actor_id(int64_t actor_id) {
print_channeler_.reset();
actor_id_ = actor_id;
}
void receive_ack_from_server(StreamBuffer *sb) {
// An ack is just a single byte, so there's nothing left to read.
if (unack_.empty()) {
@@ -201,7 +208,8 @@ public:
void receive_diff_from_server(StreamBuffer *sb) {
world_to_synchronous();
try {
actor_id_ = world_->patch_everything(sb);
int nactor = world_->patch_everything(sb);
if (nactor != actor_id_) change_actor_id(nactor);
} catch (const StreamEof &seof) {
abandon_server();
return;