#include "StringTool.h" #include "SocketObject.h" #include #include "friremote.h" #ifndef SVR_HANDLING #define SVR_HANDLING #define REAL_ROBOT false // Serve status #define SVR_NAME "lwrsvr 4.11d" #define SVR_DEFAULT_PORT 8000 #define SVR_HANDSHAKE "Hello Robot" #define SVR_HELLO_MSG std::string("welcome to ") + SVR_NAME + ("!") + (" Type \"")+ SVR_HANDSHAKE + ("\" to establish the connection") #define SVR_ACCEPTED std::string("accepted") #define SVR_FAILED std::string("Failed.") #define SVR_TRUE_RSP "true" #define SVR_FALSE_RSP "false" // server error messages #define SVR_INVALID_ARGUMENT "ERROR: The argument is not correct." #define SVR_UNIMPLEMENTED_COMMAND "ERROR: This command is jet not implemented." #define SVR_UNKNOWN_COMMAND "ERROR: This command is not correct." #define SVR_INVALID_ARGUMENT_COUNT "ERROR: The argument count is not correct." #define SVR_OUT_OF_RANGE "ERROR: At least one argument is out of Range." typedef enum {waiting, handshake, accepted, done} svr_state; class SvrHandling : private StringTool { private: svr_state c_state; //Handshake bool handshakeAccepted(SocketObject& client); //handle client commands he is disconected void clientCommandLoop(SocketObject& client); public: //Constructor SvrHandling(); //Destructor virtual ~SvrHandling(); ///Run server with default port void run(); ///Run server special port void run(int port); //Get current timestamp std::string timestamp(); }; struct ClientCommand { std::string aberration; std::string longVersion; void (*processCommand) ( SocketObject& client, std::string& argv); void (*printHelp) (void); }; #endif