#ifndef JCEF_SERVERAPPLICATION_H #define JCEF_SERVERAPPLICATION_H #include #include #include #include #include "gen-cpp/Server.h" #include "CommandLineArgs.h" class ServerHandler; class MyServerProcessorFactory; class ServerHandlerContext; class RemoteAppHandler; class CancellationPoint; class ServerApplication { explicit ServerApplication(); public: ~ServerApplication(); bool init(int argc, char* argv[]); const std::chrono::steady_clock::time_point& getStartTime() const; enum State { SS_NEW, SS_SHUTTING_DOWN, SS_SHUTDOWN }; std::string getState(); std::string getStateWithDetails(); std::shared_ptr getProcessorFactory() const; RemoteAppHandler* getCefAppHandler() { return myAppHandler; } const CommandLineArgs& getCmdArgs() const { return myCmdArgs; } std::string getRootPath() const; bool isDefaultRoot() const; void startShuttingDown(); void onBeforeExit(); static ServerApplication& instance() { return ourInstance; } std::shared_ptr getCtx(int connectionId); private: CommandLineArgs myCmdArgs; RemoteAppHandler* myAppHandler = nullptr; std::shared_ptr myFactory; State myState = SS_NEW; std::recursive_mutex myMutexState; std::chrono::steady_clock::time_point myTimeStart; std::chrono::steady_clock::time_point myTimeStartShuttingDown; std::thread myThreadWatcher; std::shared_ptr myStopWatcher; std::thread myThreadShutdown; static ServerApplication ourInstance; }; #endif // JCEF_SERVERAPPLICATION_H