24 typedef std::vector<Handler> Collection;
26 std::string
const &data);
28 enum Mode { kModeEquals, kModeStartsWith };
35 int compare(std::string
const &command)
const;
40 Handler::Collection _handlers;
41 std::vector<std::string> _lastCommands;
47 inline void setSession(
SessionBase *session) { _session = session; }
53 void onCommand(std::string
const &command, std::string
const &arguments);
56 bool registerHandler(Handler
const &handler);
58 template <
typename CallbackType>
60 registerHandler(Handler::Mode
const &mode, std::string
const &command,
61 ProtocolHandler *handler, CallbackType
const &callback) {
62 Handler _handler = {mode, command, handler, (Handler::Callback)callback};
63 return registerHandler(_handler);
67 Handler
const *findHandler(std::string
const &command,
68 size_t &commandLength)
const;
71 void onPacketData(std::string
const &data,
bool valid)
override;
72 void onInvalidData(std::string
const &data)
override;
75 inline std::vector<std::string>
const &lastCommands()
const {
78 inline void clearLastCommands() { _lastCommands.clear(); }