BlinkenArea - GitList
Repositories
Blog
Wiki
Blinker
Code
Commits
Branches
Tags
Search
Tree:
46a7c7b
Branches
Tags
master
Blinker
src
noarch
Phone.h
begin of phone connector
Stefan Schuermans
commited
46a7c7b
at 2011-12-22 14:11:23
Phone.h
Blame
History
Raw
/* Blinker Copyright 2011 Stefan Schuermans <stefan@blinkenarea.org> Copyleft GNU public license - http://www.gnu.org/copyleft/gpl.html a blinkenarea.org project */ #ifndef BLINKER_PHONE_H #define BLINKER_PHONE_H #include <string> #include "Directory.h" #include "File.h" #include "IoCallee.h" #include "Mgrs.h" #include "Module.h" #include "SettingFile.h" #include "Time.h" #include "TimeCallee.h" namespace Blinker { /// phone connector (using EBIP) template<typename ADDR, typename SOCK> class Phone: public IoCallee, public Module, public TimeCallee { protected: /// type for address setting file typedef SettingFile<ADDR> AddrFile; public: /** * @brief constructor * @param[in] mgrs managers * @param[in] dirBase base directory */ Phone(Mgrs &mgrs, const Directory &dirBase); /// virtual destructor virtual ~Phone(); private: /// copy constructor disabled Phone(const Phone &that); /// assignment operator disabled const Phone & operator=(const Phone &that); public: /// check for update of configuration virtual void updateConfig(); /// callback when requested time reached virtual void timeCall(); /** * @brief callback when I/O object is readable * @param[in] io I/O object that is readable */ virtual void ioReadCall(Io *io); /** * @brief callback when I/O object is writable * @param[in] io I/O object that is writable */ virtual void ioWriteCall(Io *io); protected: /// (re-)read server address void readServer(); /// create socket and bind it void createSock(); /// destroy socket void destroySock(); /// register with server void sendRegister(); /// send heartbeat to server void sendHeartbeat(); /** * @brief send message to server * @param[in] msg message to send */ void send(const std::string &msg); /// receive data from socket void receiveFromSock(); /// update time callback void updateTimeCallback(); protected: static const Time m_serverTimeout; static const Time m_heartbeatInterval; protected: AddrFile m_fileBind; ///< bind address file AddrFile m_fileServer; ///< server address file SOCK *m_pSock; ///< socket to use for sending messages Time m_timeRegister; ///< time to re-register Time m_timeHeartbeat; ///< time to send next heartbeat }; // class Phone } // namespace Blinker #endif // #ifndef BLINKER_PHONE_H