SimpleAI
 All Classes Namespaces Files Functions Variables Typedefs Macros Groups Pages
AddNodeHandler.h
Go to the documentation of this file.
1 
4 #pragma once
5 
6 #include "IProtocolHandler.h"
7 #include "AIAddNodeMessage.h"
8 
9 namespace ai {
10 
11 class Server;
12 
14 private:
15  Server& _server;
16 public:
17  explicit AddNodeHandler(Server& server) : _server(server) {
18  }
19 
20  void execute(const ClientId& /*clientId*/, const IProtocolMessage& message) override {
21  const AIAddNodeMessage& msg = static_cast<const AIAddNodeMessage&>(message);
22  if (!_server.addNode(msg.getCharacterId(), msg.getParentNodeId(), msg.getName(), msg.getType(), msg.getCondition())) {
23  ai_log_error("Failed to add the new node");
24  }
25  }
26 };
27 
28 }
#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
bool addNode(const CharacterId &characterId, int32_t parentNodeId, const std::string &name, const std::string &type, const std::string &condition)
Add a new node with the given values to the specified ICharacter and all the other characters that ar...
Definition: ServerImpl.h:363
Interface for the execution of assigned IProtocolMessage.
Definition: IProtocolHandler.h:19
Definition: AddNodeHandler.h:13
Message for the remote debugging interface.
Definition: AIAddNodeMessage.h:16
The server can serialize the state of the AI and broadcast it to all connected clients.
Definition: Server.h:50