IAutoTestServer.h 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. #pragma once
  2. #ifdef AUTOTEST_EXPORTS
  3. #define AUTOTEST_API __declspec(dllexport)
  4. #else
  5. #define AUTOTEST_API __declspec(dllimport)
  6. #endif
  7. #include <string>
  8. class IRequestHandler;
  9. class IWebsocketHandler;
  10. class IRequestHandler
  11. {
  12. public:
  13. virtual std::string GetResponse(void *connection, const std::string &url, const std::string &body) = 0;
  14. };
  15. class IWebsocketHandler
  16. {
  17. public:
  18. virtual std::string OnWebsocketFrame(unsigned char *framedata, size_t datalen) = 0;
  19. };
  20. class AUTOTEST_API IAutoTestServer
  21. {
  22. public:
  23. IAutoTestServer(){}
  24. virtual ~IAutoTestServer(){}
  25. virtual void Init(const std::string& port) = 0;
  26. virtual bool Start() = 0;
  27. virtual bool StartAsync() = 0;
  28. virtual bool Close() = 0;
  29. virtual void AddHandler(const std::string& url, IRequestHandler* req_handler) = 0;
  30. virtual void AddWebsocketHandler(IWebsocketHandler *handler) = 0;
  31. virtual void RemoveWebsocketHandler() = 0;
  32. virtual void RemoveHandler(const std::string& url) = 0;
  33. virtual void Response(void* connection, const std::string& resp) = 0;
  34. };
  35. AUTOTEST_API IAutoTestServer *GetAutoTestServer();