All pastes #286005 Raw Edit

Anonymous

public cpp v1 · immutable
#286005 ·published 2006-12-20 06:41 UTC
rendered paste body
    /// This class is a message handler interface which sends it's messages as human-readable strings.    class ClientMessageHandler      {      public:        /// \name Construction / destruction.        /// \{        /// \brief Constructor witho26 ut parameters.        ClientMessageHandler();        /// \brief Constructor with parameters.        /// \param smgr : Pointer to the scenemanager to execute received commands on.        ClientMessageHandler(scart::graphics::SceneManager* smgr);        /// \brief Destructor.        ~ClientMessageHandler();        /// \}        /// \name Methods        /// \{        /// \brief Parses incomming commands and executes them.        void ParseMessages();        /// \brief Broadcasts all messages in the queue.        void BroadcastMessages();        /// \brief Stores a message to be broadcasted when BroadcastMessages() is called.        /// \param message : Message to be broadcasted.        /// \return Returns the ID for this pending message.        std::string PushOutMessage(common::Command& message);        /// \brief Stores a received message.        /// \param message : Received message. (Typically passed by the network code)        void PushInMessage(common::Command& message);        /// Checks weither a message is still pending. (Server did not verify it's execution/reception yet)        /// \param ID : Message ID for the message to inquire about as passed by PushOutMessage.        /// \return True if still pending, false if the message has been verified by the server.        bool IsPending(std::string ID);        /// \brief Set a pointer to the SceneManager to receive messages from this messagehandler.        /// \param smgr : Pointer to the scene manager to which this message handler sends it's received commands to.        void SetSceneManager(scart::graphics::SceneManager* smgr);        /// \brief Pass the net driver to the message handler.        /// \param NetDriver : Pointer to the network driver.        void SetNetDriver(ClientNetDriver* NetDriver);        /// \brief Wait for the command with specified ID to be executed by the server.        /// \param ID : ID of the command to wait for.        /// \param TimeOut : TimeOut in seconds        /// \return Returns true if the command was received, false if timed out.        bool WaitFor(std::string ID,int TimeOut);        /// \brief Get the net driver assosiated with this message handler.        /// \return Returns the network driver assosiated with this message handler.        ClientNetDriver* GetNetDriver();        /// \brief Gets the scene manager        /// \return Returns pointer to the scene manager connected to this message handler.        scart::graphics::SceneManager* GetSceneManager();        /// \brief Resets the message handler.        void Reset();        /// \}        /// \name Public member variables        /// \{        /// \brief Lock/unlock this mutex when using the message handler in multiple threads.        net::scnetMutex Mutex;        /// \}      private:        /// \name Private member variables.        /// \{        /// \brief Queue of messages to send.        std::stack<common::Command> m_OutQueue;        /// \brief Queue of sent messages that have not yet received a reply.        std::vector<common::Command> m_PendingQueue;        /// \brief Queue of messages received.        std::stack<common::Command> m_InQueue;        /// \brief Stores a pointer to the scene manager.        scart::graphics::SceneManager* m_SceneManager;        /// \brief Stores a pointer to the net driver.        ClientNetDriver* m_NetDriver;        /// \brief Message counter        unsigned long m_Counter;        /// \}      };