More work on client and server
This commit is contained in:
@@ -62,6 +62,8 @@ public:
|
||||
}
|
||||
|
||||
void abandon_server() {
|
||||
stdostream() << "Abandoning server." << std::endl;
|
||||
|
||||
// Put the world model back into a known-good state.
|
||||
set_initial_state();
|
||||
|
||||
@@ -189,10 +191,11 @@ public:
|
||||
}
|
||||
|
||||
void change_actor_id(int64_t actor_id) {
|
||||
stdostream() << "Actor ID changing: " << actor_id << std::endl;
|
||||
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()) {
|
||||
@@ -208,7 +211,7 @@ public:
|
||||
void receive_diff_from_server(StreamBuffer *sb) {
|
||||
world_to_synchronous();
|
||||
try {
|
||||
int nactor = world_->patch_everything(sb);
|
||||
int64_t nactor = world_->patch_everything(sb);
|
||||
if (nactor != actor_id_) change_actor_id(nactor);
|
||||
} catch (const StreamEof &seof) {
|
||||
abandon_server();
|
||||
@@ -260,10 +263,18 @@ public:
|
||||
stdostream() << "Server closed connection " << channel_->error() << std::endl;
|
||||
abandon_server();
|
||||
} else {
|
||||
while (receive_message_from_server(channel_->in()));
|
||||
while (true) {
|
||||
if (!receive_message_from_server(channel_->in())) break;
|
||||
if (channel_ == nullptr) break;
|
||||
}
|
||||
world_to_asynchronous();
|
||||
}
|
||||
}
|
||||
|
||||
// Channel print statements.
|
||||
if (print_channeler_.channel(world_->get_printbuffer(actor_id_), stdostream())) {
|
||||
send_invocation(print_channeler_.invocation(actor_id_));
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user