BlinkenArea - GitList
Repositories
Blog
Wiki
Blinker
Code
Commits
Branches
Tags
Search
Tree:
75c7e0f
Branches
Tags
master
Blinker
src
noarch
Phone.h
implemented extension config for phone connector
Stefan Schuermans
commited
75c7e0f
at 2011-12-22 15:00:51
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 <map> #include <string> #include "Directory.h" #include "File.h" #include "IoCallee.h" #include "ListTracker.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; /// extension to be called class Extension; /// extension list tracker typedef ListTracker<Phone, Extension, Directory> ExtListTracker; /// map of extensions to call (extension name -> module name) typedef std::map<std::string, std::string> ExtMap; 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(); /** * @brief process message from server * @param[in] msg message from server */ void serverMsg(const std::string &msg); /// 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 ExtListTracker m_extListTracker; ///< extension tracker SOCK *m_pSock; ///< socket to use for sending messages Time m_timeRegister; ///< time to re-register Time m_timeHeartbeat; ///< time to send next heartbeat ExtMap m_extMap; ///< map of extensions to call }; // class Phone } // namespace Blinker #endif // #ifndef BLINKER_PHONE_H