X-Git-Url: http://developer.intra2net.com/git/?p=libt2n;a=blobdiff_plain;f=src%2Fcommand_server.hxx;h=c86b2858da60948e8db2c0d068cf753c01acbd3a;hp=2f3df5a78fd014e40ef5e451db4cb0d5a80cfb40;hb=a762a4763df16c8e38afe727921273cd929709a4;hpb=28cb45a5725e9c6054d7048a9bf969b9f2c94d64 diff --git a/src/command_server.hxx b/src/command_server.hxx index 2f3df5a..c86b285 100644 --- a/src/command_server.hxx +++ b/src/command_server.hxx @@ -19,6 +19,7 @@ #ifndef __LIBT2N_COMMAND_SERVER #define __LIBT2N_COMMAND_SERVER +#include "command.hxx" #include "server.hxx" namespace libt2n @@ -32,15 +33,37 @@ class command_server void handle_packet(const std::string& packet, server_connection* conn); + protected: + virtual command* cast_command(command* input) + { return input; } + public: command_server(server& _s); - void handle(long long usec_timeout=-1); + void handle(long long usec_timeout=-1, long long* usec_timeout_remaining=NULL); - void new_connection_callback(server_connection* conn); + void send_hello(unsigned int conn_id); }; -} +template struct Derived_from { + static void constraints(T* p) { B* pb = p; } + Derived_from() { void(*p)(T*) = constraints; } +}; + +/// server handling group of incoming commands +template +class group_command_server : public command_server +{ + private: + virtual command* cast_command(command* input) + { return dynamic_cast(input); } + public: + group_command_server(server& _s) + : command_server(_s) + { Derived_from(); } +}; + +} #endif