⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 warsvrengine.h

📁 ftpserver very good sample
💻 H
字号:
/**   The "server engine" contains rules for provided services,  and listens to all host addresses and ports that are  requiered. When a connection is made, the engine creates  the appropriate WarServerProtocol object and passes the  connection socket to this for further processing.  There can only be one server-engine instance in an   application.*/#ifndef WAR_SVR_ENGINE_H#define WAR_SVR_ENGINE_H/* SYSTEM INCLUDES *//* PROJECT INCLUDES */#ifndef WAR_EXCEPTION_H#   include "WarException.h"#endif#ifndef WAR_SVR_DEFINITION_H#   include "WarSvrDefinition.h"#endif#ifndef WAR_SOCKET_H#   include"WarSocket.h"#endif#ifndef WAR_USER_ENGINE_H#   include "WarUserEngine.h"#endif#ifndef WAR_PLUGIN_SUPPORT_H#   include "WarPluginSupport.h"#endif#ifndef WAR_SVR_PROTOCOL_H#   include "WarSvrProtocol.h"#endif/* LOCAL INCLUDES *//* FORWARD REFERENCES */class WarSvrEngineSocket;#ifdef __cplusplusextern "C" {#endif/****************** BEGIN OLD STYLE C spesific ********//****************** END OLD STYLE C spesific **********/#ifdef __cplusplus }#endif/****************** BEGIN C++ spesific ****************/#ifdef __cplusplusclass WarSvrEngine :public WarPluginSupport<WarSvrEngine> // Extendable with plugins{public:    typedef std::set<war_svr_protocol_ptr_t> svrset_t;    enum PluginEventsE    {        PLUGIN_EVENT_ON_ACCEPT,        PLUGIN_EVENT_INVALID    };    // LIFECYCLE        /**    * Default constructor.    */    WarSvrEngine(void);        /**    * Destructor.    */    ~WarSvrEngine(void);        // OPERATORS        // OPERATIONS    void Initialize() throw(WarException);    // Set pause-state. In this state, all new connections are refused    void Pause();    // Resume normal operation    void Resume();    /// Start or re-start the server.     void StartServer() throw(WarException);    // Adds a template to the server    void AddServer(war_svrdef_ptr_t serverDef)        throw(WarException);    // Remove a server from the list. Typically called on logout.    void UnregisterSession(WarSvrProtocol& from);    // ACCESS    static WarSvrEngine& GetEngine() throw(WarException)    {        if (mspThis == NULL)            WarThrow(WarError(WAR_ERR_INTERNAL_DATA_NOT_INITIALIZED), NULL);        return *mspThis;    }    // CALLBACK    static void OnShutdown(war_cptr_t ptr);    // INQUIRY    // Check if clients can play. Returns false during shutdown and paused operation    bool CanPlay() const;    protected:    friend class WarSvrEngineSocket;    virtual void OnAccept(const WarError& status,        war_socket_t newSocket,        const WarNetAddress& remoteAddress,        const WarNetAddress& localAddress,        WarSvrEngineSocket *pListenSck);    void OnShutdown();    virtual WarSocketIo *NewIoSocketForStartup() throw(WarException);    virtual WarSocketIo *NewIoSocketForClient() throw(WarException);private:    bool m_bIsShuttingDown;    static WarSvrEngine *mspThis;    war_svrdef_list_t mServices; // List of service definitions    war_socket_set_t mListeningTo; // List of sockets we listen to    svrset_t mCurrentServers; // Current user connections    WarCriticalSection mLock;    bool mIsPaused;};/* INLINE METHODS *//* EXTERNAL REFERENCES *//* PLUGIN INTERFACE */class WarSvrEngine_OnAccept : public WarPlugin{public:    static WarSvrEngine::PluginEventsE GetId()    {        return WarSvrEngine::PLUGIN_EVENT_ON_ACCEPT;    }    virtual void OnProcess(const WarError& status,        war_socket_t newSocket,        const WarNetAddress& remoteAddress,        const WarNetAddress& localAddress,        WarSvrEngineSocket *pListenSck)         throw (WarException) = 0;};#endif /* __cplusplus *//****************** END C++ spesific ******************/#endif  /* WAR_SVR_ENGINE_H_ */

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -