SimpleAI
 All Classes Namespaces Files Functions Variables Typedefs Macros Groups Pages
UpdateNodeHandler.h
Go to the documentation of this file.
1 
4 #pragma once
5 
6 #include "IProtocolHandler.h"
7 #include "AIUpdateNodeMessage.h"
8 #include "Server.h"
9 
10 namespace ai {
11 
12 class Server;
13 
15 private:
16  Server& _server;
17 public:
18  explicit UpdateNodeHandler(Server& server) : _server(server) {
19  }
20 
21  void execute(const ClientId& /*clientId*/, const IProtocolMessage& message) override {
22  const AIUpdateNodeMessage& msg = static_cast<const AIUpdateNodeMessage&>(message);
23  if (!_server.updateNode(msg.getCharacterId(), msg.getNodeId(), msg.getName(), msg.getType(), msg.getCondition())) {
24  ai_log_error("Failed to update the node %u", msg.getNodeId());
25  }
26  }
27 };
28 
29 }
#define ai_log_error(...)
Logging macro to provide your own loggers.
Definition: Types.h:23
A protocol message is used for the serialization of the ai states for remote debugging.
Definition: IProtocolMessage.h:60
Definition: UpdateNodeHandler.h:14
bool updateNode(const CharacterId &characterId, int32_t nodeId, const std::string &name, const std::string &type, const std::string &condition)
Update the specified node with the given values for the specified ICharacter and all the other charac...
Definition: ServerImpl.h:317
Interface for the execution of assigned IProtocolMessage.
Definition: IProtocolHandler.h:19
Message for the remote debugging interface.
Definition: AIUpdateNodeMessage.h:16
The server can serialize the state of the AI and broadcast it to all connected clients.
Definition: Server.h:50