13constexpr std::size_t kChatLines = 100;
18 protocol::World
world;
19 if (!
world.ParseFromArray(message.data(),
static_cast<int>(message.size()))) {
20 return absl::DataLossError(
"couldn't read the server's message");
24 if (
world.has_move()) {
26 }
else if (
world.has_inventory()) {
27 inventory_ =
world.inventory();
28 }
else if (
world.has_quests()) {
29 quests_ =
world.quests();
30 }
else if (
world.has_guild()) {
31 guild_ =
world.guild();
32 }
else if (
world.has_trade()) {
33 trade_ =
world.trade();
34 }
else if (
world.has_duel()) {
36 }
else if (
world.has_invite()) {
37 invite_ =
world.invite();
38 }
else if (!
world.events().empty()) {
39 events_.insert(events_.end(),
world.events().begin(),
world.events().end());
40 }
else if (
world.chat().empty()) {
43 chat_.insert(chat_.end(),
world.chat().begin(),
world.chat().end());
44 while (chat_.size() > kChatLines) {
48 return absl::OkStatus();
53 world_ = parts_.world();
57 return std::exchange(events_, {});
61 return std::exchange(invite_, std::nullopt);
void Add(const protocol::World &part)
A part of the world that came on its own, as a datagram brings it.
const protocol::World & world() const
std::vector< protocol::Event > TakeEvents()
The events since the last time, oldest first, handed over once.
std::optional< protocol::GuildInvite > TakeInvite()
The guild that asked us to join since the last time, once.
absl::Status Take(std::string_view message)
Files one of the server's messages, or returns why it isn't one.