f670ca05dd608c9d5b0300ca1dc493f6ffd8afa1
Stefan Schuermans begin of phone connector

Stefan Schuermans authored 12 years ago

src/noarch/Phone_impl.h   1) /* Blinker
Stefan Schuermans update copyright years

Stefan Schuermans authored 10 years ago

src/noarch/Phone_impl.h   2)    Copyright 2011-2014 Stefan Schuermans <stefan@blinkenarea.org>
Stefan Schuermans begin of phone connector

Stefan Schuermans authored 12 years ago

src/noarch/Phone_impl.h   3)    Copyleft GNU public license - http://www.gnu.org/copyleft/gpl.html
src/noarch/Phone_impl.h   4)    a blinkenarea.org project */
src/noarch/Phone_impl.h   5) 
src/noarch/Phone_impl.h   6) #ifndef BLINKER_PHONE_IMPL_H
src/noarch/Phone_impl.h   7) #define BLINKER_PHONE_IMPL_H
src/noarch/Phone_impl.h   8) 
Stefan Schuermans clarified operator connecti...

Stefan Schuermans authored 12 years ago

src/noarch/Phone_impl.h   9) #include <map>
Stefan Schuermans phone connector module basi...

Stefan Schuermans authored 12 years ago

src/noarch/Phone_impl.h  10) #include <sstream>
Stefan Schuermans begin of phone connector

Stefan Schuermans authored 12 years ago

src/noarch/Phone_impl.h  11) #include <string>
Stefan Schuermans clarified operator connecti...

Stefan Schuermans authored 12 years ago

src/noarch/Phone_impl.h  12) #include <vector>
Stefan Schuermans begin of phone connector

Stefan Schuermans authored 12 years ago

src/noarch/Phone_impl.h  13) 
src/noarch/Phone_impl.h  14) #include "Directory.h"
src/noarch/Phone_impl.h  15) #include "File.h"
src/noarch/Phone_impl.h  16) #include "IoCallee.h"
Stefan Schuermans implemented extension confi...

Stefan Schuermans authored 12 years ago

src/noarch/Phone_impl.h  17) #include "ListTracker.h"
src/noarch/Phone_impl.h  18) #include "ListTracker_impl.h"
Stefan Schuermans begin of phone connector

Stefan Schuermans authored 12 years ago

src/noarch/Phone_impl.h  19) #include "Mgrs.h"
src/noarch/Phone_impl.h  20) #include "Module.h"
Stefan Schuermans phone connector module basi...

Stefan Schuermans authored 12 years ago

src/noarch/Phone_impl.h  21) #include "OpConn.h"
src/noarch/Phone_impl.h  22) #include "OpConnIf.h"
src/noarch/Phone_impl.h  23) #include "OpMgr.h"
Stefan Schuermans begin of phone connector

Stefan Schuermans authored 12 years ago

src/noarch/Phone_impl.h  24) #include "Phone.h"
Stefan Schuermans implemented extension confi...

Stefan Schuermans authored 12 years ago

src/noarch/Phone_impl.h  25) #include "PhoneExtension.h"
src/noarch/Phone_impl.h  26) #include "PhoneExtension_impl.h"
Stefan Schuermans begin of phone connector

Stefan Schuermans authored 12 years ago

src/noarch/Phone_impl.h  27) #include "SettingFile.h"
Stefan Schuermans implemented extension confi...

Stefan Schuermans authored 12 years ago

src/noarch/Phone_impl.h  28) #include "StringParser.h"
Stefan Schuermans begin of phone connector

Stefan Schuermans authored 12 years ago

src/noarch/Phone_impl.h  29) #include "Time.h"
src/noarch/Phone_impl.h  30) #include "TimeCallee.h"
src/noarch/Phone_impl.h  31) 
src/noarch/Phone_impl.h  32) namespace Blinker {
src/noarch/Phone_impl.h  33) 
src/noarch/Phone_impl.h  34) /**
src/noarch/Phone_impl.h  35)  * @brief constructor
Stefan Schuermans make modules know their name

Stefan Schuermans authored 12 years ago

src/noarch/Phone_impl.h  36)  * @param[in] name module name
Stefan Schuermans begin of phone connector

Stefan Schuermans authored 12 years ago

src/noarch/Phone_impl.h  37)  * @param[in] mgrs managers
src/noarch/Phone_impl.h  38)  * @param[in] dirBase base directory
src/noarch/Phone_impl.h  39)  */
src/noarch/Phone_impl.h  40) template<typename ADDR, typename SOCK>
Stefan Schuermans make modules know their name

Stefan Schuermans authored 12 years ago

src/noarch/Phone_impl.h  41) Phone<ADDR, SOCK>::Phone(const std::string &name, Mgrs &mgrs,
src/noarch/Phone_impl.h  42)                          const Directory &dirBase):
src/noarch/Phone_impl.h  43)   Module(name, mgrs, dirBase),
Stefan Schuermans begin of phone connector

Stefan Schuermans authored 12 years ago

src/noarch/Phone_impl.h  44)   m_fileBind(dirBase.getFile("bind")),
src/noarch/Phone_impl.h  45)   m_fileServer(dirBase.getFile("server")),
Stefan Schuermans implemented extension confi...

Stefan Schuermans authored 12 years ago

src/noarch/Phone_impl.h  46)   m_extListTracker(*this, dirBase.getSubdir("extensions")),
Stefan Schuermans begin of phone connector

Stefan Schuermans authored 12 years ago

src/noarch/Phone_impl.h  47)   m_pSock(NULL)
src/noarch/Phone_impl.h  48) {
src/noarch/Phone_impl.h  49)   // read server address
src/noarch/Phone_impl.h  50)   readServer();
src/noarch/Phone_impl.h  51) 
src/noarch/Phone_impl.h  52)   // create and bind socket
src/noarch/Phone_impl.h  53)   createSock();
Stefan Schuermans implemented extension confi...

Stefan Schuermans authored 12 years ago

src/noarch/Phone_impl.h  54) 
src/noarch/Phone_impl.h  55)   // load extensions
src/noarch/Phone_impl.h  56)   m_extListTracker.init();
Stefan Schuermans begin of phone connector

Stefan Schuermans authored 12 years ago

src/noarch/Phone_impl.h  57) }
src/noarch/Phone_impl.h  58) 
src/noarch/Phone_impl.h  59) /// virtual destructor
src/noarch/Phone_impl.h  60) template<typename ADDR, typename SOCK>
src/noarch/Phone_impl.h  61) Phone<ADDR, SOCK>::~Phone()
src/noarch/Phone_impl.h  62) {
Stefan Schuermans implemented extension confi...

Stefan Schuermans authored 12 years ago

src/noarch/Phone_impl.h  63)   // unload extensions
src/noarch/Phone_impl.h  64)   m_extListTracker.clear();
src/noarch/Phone_impl.h  65) 
Stefan Schuermans phone connector module basi...

Stefan Schuermans authored 12 years ago

src/noarch/Phone_impl.h  66)   // close all connections
src/noarch/Phone_impl.h  67)   while (!m_connLineMap.empty()) {
src/noarch/Phone_impl.h  68)     ConnLineMap::iterator it = m_connLineMap.begin();
src/noarch/Phone_impl.h  69)     it->first->close();
src/noarch/Phone_impl.h  70)     sendHangup(it->second);
src/noarch/Phone_impl.h  71)     m_connLineMap.erase(it);
src/noarch/Phone_impl.h  72)   }
src/noarch/Phone_impl.h  73) 
Stefan Schuermans begin of phone connector

Stefan Schuermans authored 12 years ago

src/noarch/Phone_impl.h  74)   // destroy socket
src/noarch/Phone_impl.h  75)   destroySock();
src/noarch/Phone_impl.h  76) 
src/noarch/Phone_impl.h  77)   // cancel time callback
src/noarch/Phone_impl.h  78)   m_mgrs.m_callMgr.cancelTimeCall(this);
src/noarch/Phone_impl.h  79) }
src/noarch/Phone_impl.h  80) 
src/noarch/Phone_impl.h  81) /// check for update of configuration
src/noarch/Phone_impl.h  82) template<typename ADDR, typename SOCK>
src/noarch/Phone_impl.h  83) void Phone<ADDR, SOCK>::updateConfig()
src/noarch/Phone_impl.h  84) {
src/noarch/Phone_impl.h  85)   // bind address file was modified -> re-create socket
src/noarch/Phone_impl.h  86)   if (m_fileBind.checkModified()) {
src/noarch/Phone_impl.h  87)     destroySock();
src/noarch/Phone_impl.h  88)     createSock();
src/noarch/Phone_impl.h  89)   }
src/noarch/Phone_impl.h  90) 
src/noarch/Phone_impl.h  91)   // server address file was modified -> re-read server address
src/noarch/Phone_impl.h  92)   if (m_fileServer.checkModified())
src/noarch/Phone_impl.h  93)     readServer();
Stefan Schuermans implemented extension confi...

Stefan Schuermans authored 12 years ago

src/noarch/Phone_impl.h  94) 
src/noarch/Phone_impl.h  95)   // extensions update
src/noarch/Phone_impl.h  96)   m_extListTracker.updateConfig();
Stefan Schuermans begin of phone connector

Stefan Schuermans authored 12 years ago

src/noarch/Phone_impl.h  97) }
src/noarch/Phone_impl.h  98) 
src/noarch/Phone_impl.h  99) /// callback when requested time reached
src/noarch/Phone_impl.h 100) template<typename ADDR, typename SOCK>
src/noarch/Phone_impl.h 101) void Phone<ADDR, SOCK>::timeCall()
src/noarch/Phone_impl.h 102) {
src/noarch/Phone_impl.h 103)   Time now = Time::now();
src/noarch/Phone_impl.h 104) 
src/noarch/Phone_impl.h 105)   // server timeout -> re-register
src/noarch/Phone_impl.h 106)   if (m_timeRegister <= now)
src/noarch/Phone_impl.h 107)     sendRegister();
src/noarch/Phone_impl.h 108) 
src/noarch/Phone_impl.h 109)   // send heartbeat
src/noarch/Phone_impl.h 110)   if (m_timeHeartbeat <= now)
src/noarch/Phone_impl.h 111)     sendHeartbeat();
src/noarch/Phone_impl.h 112) }
src/noarch/Phone_impl.h 113) 
src/noarch/Phone_impl.h 114) /**
src/noarch/Phone_impl.h 115)  * @brief callback when I/O object is readable
src/noarch/Phone_impl.h 116)  * @param[in] io I/O object that is readable
src/noarch/Phone_impl.h 117)  */
src/noarch/Phone_impl.h 118) template<typename ADDR, typename SOCK>
src/noarch/Phone_impl.h 119) void Phone<ADDR, SOCK>::ioReadCall(Io *io)
src/noarch/Phone_impl.h 120) {
src/noarch/Phone_impl.h 121)   // reception on socket
src/noarch/Phone_impl.h 122)   if (io == m_pSock)
src/noarch/Phone_impl.h 123)     receiveFromSock();
src/noarch/Phone_impl.h 124) }
src/noarch/Phone_impl.h 125) 
src/noarch/Phone_impl.h 126) /**
src/noarch/Phone_impl.h 127)  * @brief callback when I/O object is writable
src/noarch/Phone_impl.h 128)  * @param[in] io I/O object that is writable
src/noarch/Phone_impl.h 129)  */
src/noarch/Phone_impl.h 130) template<typename ADDR, typename SOCK>
src/noarch/Phone_impl.h 131) void Phone<ADDR, SOCK>::ioWriteCall(Io *io)
src/noarch/Phone_impl.h 132) {
src/noarch/Phone_impl.h 133)   (void)io; // unused
src/noarch/Phone_impl.h 134) }
src/noarch/Phone_impl.h 135) 
Stefan Schuermans implemented play and key me...

Stefan Schuermans authored 12 years ago

src/noarch/Phone_impl.h 136) /**
src/noarch/Phone_impl.h 137)  * @brief key command received on operator connection
src/noarch/Phone_impl.h 138)  * @param[in] pConn operator connection object
src/noarch/Phone_impl.h 139)  * @param[in] key key that was pressed
src/noarch/Phone_impl.h 140)  */
src/noarch/Phone_impl.h 141) template<typename ADDR, typename SOCK>
src/noarch/Phone_impl.h 142) void Phone<ADDR, SOCK>::opConnRecvKey(OpConn *pConn, char key)
src/noarch/Phone_impl.h 143) {
src/noarch/Phone_impl.h 144)   // the key command does not make sense in this direction, ignore it
src/noarch/Phone_impl.h 145)   (void)pConn; // unused
src/noarch/Phone_impl.h 146)   (void)key; // unused
src/noarch/Phone_impl.h 147) }
src/noarch/Phone_impl.h 148) 
src/noarch/Phone_impl.h 149) /**
src/noarch/Phone_impl.h 150)  * @brief play command received on operator connection
src/noarch/Phone_impl.h 151)  * @param[in] pConn operator connection object
src/noarch/Phone_impl.h 152)  * @param[in] sound name of sound to play
src/noarch/Phone_impl.h 153)  */
src/noarch/Phone_impl.h 154) template<typename ADDR, typename SOCK>
src/noarch/Phone_impl.h 155) void Phone<ADDR, SOCK>::opConnRecvPlay(OpConn *pConn, const std::string &sound)
src/noarch/Phone_impl.h 156) {
src/noarch/Phone_impl.h 157)   // get phone line of connection
src/noarch/Phone_impl.h 158)   unsigned int line;
src/noarch/Phone_impl.h 159)   if (!conn2line(pConn, line))
src/noarch/Phone_impl.h 160)     return;
src/noarch/Phone_impl.h 161) 
src/noarch/Phone_impl.h 162)   // send play message
src/noarch/Phone_impl.h 163)   sendPlay(line, sound);
src/noarch/Phone_impl.h 164) }
src/noarch/Phone_impl.h 165) 
Stefan Schuermans phone connector module basi...

Stefan Schuermans authored 12 years ago

src/noarch/Phone_impl.h 166) /**
src/noarch/Phone_impl.h 167)  * @brief operator connection is closed
src/noarch/Phone_impl.h 168)  * @param[in] pConn operator connection object
Stefan Schuermans clarified operator connecti...

Stefan Schuermans authored 12 years ago

src/noarch/Phone_impl.h 169)  *
src/noarch/Phone_impl.h 170)  * The connection may not be used for sending any more in this callback.
Stefan Schuermans phone connector module basi...

Stefan Schuermans authored 12 years ago

src/noarch/Phone_impl.h 171)  */
src/noarch/Phone_impl.h 172) template<typename ADDR, typename SOCK>
src/noarch/Phone_impl.h 173) void Phone<ADDR, SOCK>::opConnClose(OpConn *pConn)
src/noarch/Phone_impl.h 174) {
src/noarch/Phone_impl.h 175)   // get phone line of connection
Stefan Schuermans implemented play and key me...

Stefan Schuermans authored 12 years ago

src/noarch/Phone_impl.h 176)   unsigned int line;
src/noarch/Phone_impl.h 177)   if (!conn2line(pConn, line))
Stefan Schuermans phone connector module basi...

Stefan Schuermans authored 12 years ago

src/noarch/Phone_impl.h 178)     return;
src/noarch/Phone_impl.h 179) 
src/noarch/Phone_impl.h 180)   // send hangup message
src/noarch/Phone_impl.h 181)   sendHangup(line);
src/noarch/Phone_impl.h 182) 
src/noarch/Phone_impl.h 183)   // remove connection from maps
Stefan Schuermans implemented play and key me...

Stefan Schuermans authored 12 years ago

src/noarch/Phone_impl.h 184)   m_connLineMap.erase(pConn);
Stefan Schuermans phone connector module basi...

Stefan Schuermans authored 12 years ago

src/noarch/Phone_impl.h 185)   m_lineConnMap.erase(line);
Stefan Schuermans clarified operator connecti...

Stefan Schuermans authored 12 years ago

src/noarch/Phone_impl.h 186) 
src/noarch/Phone_impl.h 187)   // remove command buffer for this line
src/noarch/Phone_impl.h 188)   m_cmdBufMap.erase(line);
Stefan Schuermans phone connector module basi...

Stefan Schuermans authored 12 years ago

src/noarch/Phone_impl.h 189) }
src/noarch/Phone_impl.h 190) 
Stefan Schuermans begin of phone connector

Stefan Schuermans authored 12 years ago

src/noarch/Phone_impl.h 191) /// (re-)read server address
src/noarch/Phone_impl.h 192) template<typename ADDR, typename SOCK>
src/noarch/Phone_impl.h 193) void Phone<ADDR, SOCK>::readServer()
src/noarch/Phone_impl.h 194) {
src/noarch/Phone_impl.h 195)   m_fileServer.update();
src/noarch/Phone_impl.h 196) 
src/noarch/Phone_impl.h 197)   // register with new server
src/noarch/Phone_impl.h 198)   sendRegister();
src/noarch/Phone_impl.h 199) }
src/noarch/Phone_impl.h 200) 
src/noarch/Phone_impl.h 201) /// create socket and bind it
src/noarch/Phone_impl.h 202) template<typename ADDR, typename SOCK>
src/noarch/Phone_impl.h 203) void Phone<ADDR, SOCK>::createSock()
src/noarch/Phone_impl.h 204) {
src/noarch/Phone_impl.h 205)   // create socket
src/noarch/Phone_impl.h 206)   if (!m_pSock) {
src/noarch/Phone_impl.h 207)     m_pSock = new SOCK();
src/noarch/Phone_impl.h 208)     if (!m_pSock)
src/noarch/Phone_impl.h 209)       return;
src/noarch/Phone_impl.h 210)   }
src/noarch/Phone_impl.h 211) 
src/noarch/Phone_impl.h 212)   // get bind address from bind address setting file
src/noarch/Phone_impl.h 213)   m_fileBind.update();
src/noarch/Phone_impl.h 214)   if (!m_fileBind.m_valid) {
src/noarch/Phone_impl.h 215)     delete m_pSock;
src/noarch/Phone_impl.h 216)     m_pSock = NULL;
src/noarch/Phone_impl.h 217)     return;
src/noarch/Phone_impl.h 218)   }
src/noarch/Phone_impl.h 219) 
src/noarch/Phone_impl.h 220)   // bind socket
src/noarch/Phone_impl.h 221)   if (!m_pSock->bind(m_fileBind.m_obj)) {
src/noarch/Phone_impl.h 222)     delete m_pSock;
src/noarch/Phone_impl.h 223)     m_pSock = NULL;
src/noarch/Phone_impl.h 224)     return;
src/noarch/Phone_impl.h 225)   }
src/noarch/Phone_impl.h 226) 
src/noarch/Phone_impl.h 227)   // request callback on recepetion
src/noarch/Phone_impl.h 228)   m_mgrs.m_callMgr.requestIoReadCall(this, m_pSock);
src/noarch/Phone_impl.h 229) 
src/noarch/Phone_impl.h 230)   // register with server
src/noarch/Phone_impl.h 231)   sendRegister();
src/noarch/Phone_impl.h 232) }
src/noarch/Phone_impl.h 233) 
src/noarch/Phone_impl.h 234) /// destroy socket
src/noarch/Phone_impl.h 235) template<typename ADDR, typename SOCK>
src/noarch/Phone_impl.h 236) void Phone<ADDR, SOCK>::destroySock()
src/noarch/Phone_impl.h 237) {
src/noarch/Phone_impl.h 238)   // cancel callback request
src/noarch/Phone_impl.h 239)   m_mgrs.m_callMgr.cancelIoReadCall(this, m_pSock);
src/noarch/Phone_impl.h 240) 
src/noarch/Phone_impl.h 241)   // destroy socket
src/noarch/Phone_impl.h 242)   if (m_pSock) {
src/noarch/Phone_impl.h 243)     delete m_pSock;
src/noarch/Phone_impl.h 244)     m_pSock = NULL;
src/noarch/Phone_impl.h 245)   }
src/noarch/Phone_impl.h 246) }
src/noarch/Phone_impl.h 247) 
src/noarch/Phone_impl.h 248) /// register with server
src/noarch/Phone_impl.h 249) template<typename ADDR, typename SOCK>
src/noarch/Phone_impl.h 250) void Phone<ADDR, SOCK>::sendRegister()
src/noarch/Phone_impl.h 251) {
Stefan Schuermans register message contains p...

Stefan Schuermans authored 12 years ago

src/noarch/Phone_impl.h 252)   ADDR addr;
src/noarch/Phone_impl.h 253)   if (m_pSock)
src/noarch/Phone_impl.h 254)     m_pSock->getAddr(addr);
src/noarch/Phone_impl.h 255)   std::stringstream strm;
src/noarch/Phone_impl.h 256)   strm << "register:" << addr.getPort();
src/noarch/Phone_impl.h 257)   sendNow(0, strm.str());
Stefan Schuermans begin of phone connector

Stefan Schuermans authored 12 years ago

src/noarch/Phone_impl.h 258) 
src/noarch/Phone_impl.h 259)   // set time for next register message and next heartbeat
BlinkenArea fix EBIP timeout and heartbeat

BlinkenArea authored 12 years ago

src/noarch/Phone_impl.h 260)   Time now = Time::now();
src/noarch/Phone_impl.h 261)   m_timeRegister = now + m_serverTimeout;
src/noarch/Phone_impl.h 262)   m_timeHeartbeat = now + m_heartbeatInterval;
Stefan Schuermans begin of phone connector

Stefan Schuermans authored 12 years ago

src/noarch/Phone_impl.h 263)   updateTimeCallback();
src/noarch/Phone_impl.h 264) }
src/noarch/Phone_impl.h 265) 
src/noarch/Phone_impl.h 266) /// send heartbeat to server
src/noarch/Phone_impl.h 267) template<typename ADDR, typename SOCK>
src/noarch/Phone_impl.h 268) void Phone<ADDR, SOCK>::sendHeartbeat()
src/noarch/Phone_impl.h 269) {
Stefan Schuermans clarified operator connecti...

Stefan Schuermans authored 12 years ago

src/noarch/Phone_impl.h 270)   sendNow(0, "heartbeat");
Stefan Schuermans begin of phone connector

Stefan Schuermans authored 12 years ago

src/noarch/Phone_impl.h 271) 
src/noarch/Phone_impl.h 272)   // set time for next heartbeat
src/noarch/Phone_impl.h 273)   m_timeHeartbeat = Time::now() + m_heartbeatInterval;
src/noarch/Phone_impl.h 274)   updateTimeCallback();
src/noarch/Phone_impl.h 275) }
src/noarch/Phone_impl.h 276) 
Stefan Schuermans implemented play and key me...

Stefan Schuermans authored 12 years ago

src/noarch/Phone_impl.h 277) /**
src/noarch/Phone_impl.h 278)  * @brief send play message
src/noarch/Phone_impl.h 279)  * @param[in] line number of line to request play on
src/noarch/Phone_impl.h 280)  * @param[in] sound name of sound to request
src/noarch/Phone_impl.h 281)  */
src/noarch/Phone_impl.h 282) template<typename ADDR, typename SOCK>
src/noarch/Phone_impl.h 283) void Phone<ADDR, SOCK>::sendPlay(unsigned int line, const std::string &sound)
src/noarch/Phone_impl.h 284) {
src/noarch/Phone_impl.h 285)   std::stringstream strm;
Stefan Schuermans clarified operator connecti...

Stefan Schuermans authored 12 years ago

src/noarch/Phone_impl.h 286)   strm << "playbackground:" << sound;
src/noarch/Phone_impl.h 287)   sendBuf(line, strm.str());
Stefan Schuermans implemented play and key me...

Stefan Schuermans authored 12 years ago

src/noarch/Phone_impl.h 288) }
src/noarch/Phone_impl.h 289) 
Stefan Schuermans phone connector module basi...

Stefan Schuermans authored 12 years ago

src/noarch/Phone_impl.h 290) /**
src/noarch/Phone_impl.h 291)  * @brief send hangup message
src/noarch/Phone_impl.h 292)  * @param[in] line number of line to hangup
src/noarch/Phone_impl.h 293)  */
src/noarch/Phone_impl.h 294) template<typename ADDR, typename SOCK>
src/noarch/Phone_impl.h 295) void Phone<ADDR, SOCK>::sendHangup(unsigned int line)
src/noarch/Phone_impl.h 296) {
BlinkenArea fix hangup command for EBIP...

BlinkenArea authored 12 years ago

src/noarch/Phone_impl.h 297)   sendNow(line, "hangup:18"); // nobody knows what the 18 meanas
Stefan Schuermans phone connector module basi...

Stefan Schuermans authored 12 years ago

src/noarch/Phone_impl.h 298) }
src/noarch/Phone_impl.h 299) 
Stefan Schuermans accepting EBIP calls works now

Stefan Schuermans authored 12 years ago

src/noarch/Phone_impl.h 300) /**
src/noarch/Phone_impl.h 301)  * @brief send accept message
src/noarch/Phone_impl.h 302)  * @param[in] line number of line accept on
src/noarch/Phone_impl.h 303)  */
src/noarch/Phone_impl.h 304) template<typename ADDR, typename SOCK>
src/noarch/Phone_impl.h 305) void Phone<ADDR, SOCK>::sendAccept(unsigned int line)
Stefan Schuermans clarified operator connecti...

Stefan Schuermans authored 12 years ago

src/noarch/Phone_impl.h 306) {
src/noarch/Phone_impl.h 307)   sendNow(line, "accept");
src/noarch/Phone_impl.h 308) }
src/noarch/Phone_impl.h 309) 
src/noarch/Phone_impl.h 310) /**
src/noarch/Phone_impl.h 311)  * @brief send message buffered to server
src/noarch/Phone_impl.h 312)  * @param[in] line number of line to hangup
src/noarch/Phone_impl.h 313)  * @param[in] msg message to send
src/noarch/Phone_impl.h 314)  */
src/noarch/Phone_impl.h 315) template<typename ADDR, typename SOCK>
src/noarch/Phone_impl.h 316) void Phone<ADDR, SOCK>::sendBuf(unsigned int line, const std::string &msg)
src/noarch/Phone_impl.h 317) {
src/noarch/Phone_impl.h 318)   CmdBufMap::iterator itCmdBuf = m_cmdBufMap.find(line);
src/noarch/Phone_impl.h 319)   // line not yet connected -> buffer command
src/noarch/Phone_impl.h 320)   if (itCmdBuf != m_cmdBufMap.end())
src/noarch/Phone_impl.h 321)     // buffer command
src/noarch/Phone_impl.h 322)     itCmdBuf->second.push_back(msg);
src/noarch/Phone_impl.h 323)   // line is connected -> send now
src/noarch/Phone_impl.h 324)   else
src/noarch/Phone_impl.h 325)     sendNow(line, msg);
src/noarch/Phone_impl.h 326) }
src/noarch/Phone_impl.h 327) 
src/noarch/Phone_impl.h 328) /**
src/noarch/Phone_impl.h 329)  * @brief send message to server now
src/noarch/Phone_impl.h 330)  * @param[in] line number of line to hangup
src/noarch/Phone_impl.h 331)  * @param[in] msg message to send
src/noarch/Phone_impl.h 332)  */
src/noarch/Phone_impl.h 333) template<typename ADDR, typename SOCK>
src/noarch/Phone_impl.h 334) void Phone<ADDR, SOCK>::sendNow(unsigned int line, const std::string &msg)
Stefan Schuermans accepting EBIP calls works now

Stefan Schuermans authored 12 years ago

src/noarch/Phone_impl.h 335) {
src/noarch/Phone_impl.h 336)   std::stringstream strm;
Stefan Schuermans clarified operator connecti...

Stefan Schuermans authored 12 years ago

src/noarch/Phone_impl.h 337)   strm << line << ":" << msg;
src/noarch/Phone_impl.h 338)   sendSock(strm.str());
Stefan Schuermans accepting EBIP calls works now

Stefan Schuermans authored 12 years ago

src/noarch/Phone_impl.h 339) }
src/noarch/Phone_impl.h 340) 
Stefan Schuermans begin of phone connector

Stefan Schuermans authored 12 years ago

src/noarch/Phone_impl.h 341) /**
Stefan Schuermans clarified operator connecti...

Stefan Schuermans authored 12 years ago

src/noarch/Phone_impl.h 342)  * @brief send message to socket
Stefan Schuermans begin of phone connector

Stefan Schuermans authored 12 years ago

src/noarch/Phone_impl.h 343)  * @param[in] msg message to send
src/noarch/Phone_impl.h 344)  */
src/noarch/Phone_impl.h 345) template<typename ADDR, typename SOCK>
Stefan Schuermans clarified operator connecti...

Stefan Schuermans authored 12 years ago

src/noarch/Phone_impl.h 346) void Phone<ADDR, SOCK>::sendSock(const std::string &msg)
Stefan Schuermans begin of phone connector

Stefan Schuermans authored 12 years ago

src/noarch/Phone_impl.h 347) {
src/noarch/Phone_impl.h 348)   // check that there is a socket and a server address
src/noarch/Phone_impl.h 349)   if (!m_pSock || !m_fileServer.m_valid)
src/noarch/Phone_impl.h 350)     return;
src/noarch/Phone_impl.h 351) 
src/noarch/Phone_impl.h 352)   // send message
src/noarch/Phone_impl.h 353)   m_pSock->send(msg, m_fileServer.m_obj);
src/noarch/Phone_impl.h 354) }
src/noarch/Phone_impl.h 355) 
src/noarch/Phone_impl.h 356) /// receive data from socket
src/noarch/Phone_impl.h 357) template<typename ADDR, typename SOCK>
src/noarch/Phone_impl.h 358) void Phone<ADDR, SOCK>::receiveFromSock()
src/noarch/Phone_impl.h 359) {
src/noarch/Phone_impl.h 360)   std::string msg;
src/noarch/Phone_impl.h 361)   ADDR addr;
src/noarch/Phone_impl.h 362) 
src/noarch/Phone_impl.h 363)   // make sure socket exists
src/noarch/Phone_impl.h 364)   if (!m_pSock)
src/noarch/Phone_impl.h 365)     return;
src/noarch/Phone_impl.h 366) 
src/noarch/Phone_impl.h 367)   // receive (leave if no reception)
src/noarch/Phone_impl.h 368)   if (!m_pSock->recv(msg, addr))
src/noarch/Phone_impl.h 369)     return;
src/noarch/Phone_impl.h 370) 
BlinkenArea accept server messages from...

BlinkenArea authored 12 years ago

src/noarch/Phone_impl.h 371)   // check that packet came from server address (but ignore port)
src/noarch/Phone_impl.h 372)   if (!m_fileServer.m_valid)
src/noarch/Phone_impl.h 373)     return; // no server configured
src/noarch/Phone_impl.h 374)   addr.setPort(m_fileServer.m_obj.getPort());
src/noarch/Phone_impl.h 375)   if (addr != m_fileServer.m_obj)
Stefan Schuermans begin of phone connector

Stefan Schuermans authored 12 years ago

src/noarch/Phone_impl.h 376)     return; // mismatch
src/noarch/Phone_impl.h 377) 
src/noarch/Phone_impl.h 378)   // reset server timeout
src/noarch/Phone_impl.h 379)   m_timeRegister = Time::now() + m_serverTimeout;
src/noarch/Phone_impl.h 380)   updateTimeCallback();
src/noarch/Phone_impl.h 381) 
Stefan Schuermans implemented extension confi...

Stefan Schuermans authored 12 years ago

src/noarch/Phone_impl.h 382)   // process message
src/noarch/Phone_impl.h 383)   serverMsg(msg);
src/noarch/Phone_impl.h 384) }
src/noarch/Phone_impl.h 385) 
src/noarch/Phone_impl.h 386) /**
src/noarch/Phone_impl.h 387)  * @brief process message from server
src/noarch/Phone_impl.h 388)  * @param[in] msg message from server
src/noarch/Phone_impl.h 389)  */
src/noarch/Phone_impl.h 390) template<typename ADDR, typename SOCK>
src/noarch/Phone_impl.h 391) void Phone<ADDR, SOCK>::serverMsg(const std::string &msg)
src/noarch/Phone_impl.h 392) {
src/noarch/Phone_impl.h 393)   // get line number and command
Stefan Schuermans phone connector module basi...

Stefan Schuermans authored 12 years ago

src/noarch/Phone_impl.h 394)   StringParser parser(msg);
Stefan Schuermans implemented extension confi...

Stefan Schuermans authored 12 years ago

src/noarch/Phone_impl.h 395)   unsigned int line;
src/noarch/Phone_impl.h 396)   std::string cmd;
src/noarch/Phone_impl.h 397)   if (!parser.uintNo(line) || !parser.fixChr(':') ||
src/noarch/Phone_impl.h 398)       !parser.untilDelim(":", false, cmd))
src/noarch/Phone_impl.h 399)     return;
Stefan Schuermans clarified operator connecti...

Stefan Schuermans authored 12 years ago

src/noarch/Phone_impl.h 400)   if (line < 1) // we are only interested in real lines here
src/noarch/Phone_impl.h 401)     return;
Stefan Schuermans implemented extension confi...

Stefan Schuermans authored 12 years ago

src/noarch/Phone_impl.h 402) 
src/noarch/Phone_impl.h 403)   // incoming call
src/noarch/Phone_impl.h 404)   if (cmd == "setup") {
src/noarch/Phone_impl.h 405)     std::string caller, extension;
src/noarch/Phone_impl.h 406)     if (!parser.fixChr(':') || !parser.untilDelim(":", true, caller) ||
src/noarch/Phone_impl.h 407)         !parser.fixChr(':') || !parser.untilDelim(":", false, extension))
src/noarch/Phone_impl.h 408)       return;
Stefan Schuermans phone connector module basi...

Stefan Schuermans authored 12 years ago

src/noarch/Phone_impl.h 409)     incomingCall(line, extension);
Stefan Schuermans implemented extension confi...

Stefan Schuermans authored 12 years ago

src/noarch/Phone_impl.h 410)   }
src/noarch/Phone_impl.h 411) 
Stefan Schuermans clarified operator connecti...

Stefan Schuermans authored 12 years ago

src/noarch/Phone_impl.h 412)   // call connected
src/noarch/Phone_impl.h 413)   else if (cmd == "connected") {
src/noarch/Phone_impl.h 414)     connected(line);
src/noarch/Phone_impl.h 415)   }
src/noarch/Phone_impl.h 416) 
Stefan Schuermans implemented extension confi...

Stefan Schuermans authored 12 years ago

src/noarch/Phone_impl.h 417)   // hangup
src/noarch/Phone_impl.h 418)   else if (cmd == "onhook") {
Stefan Schuermans phone connector module basi...

Stefan Schuermans authored 12 years ago

src/noarch/Phone_impl.h 419)     hangup(line);
Stefan Schuermans implemented extension confi...

Stefan Schuermans authored 12 years ago

src/noarch/Phone_impl.h 420)   }
src/noarch/Phone_impl.h 421) 
src/noarch/Phone_impl.h 422)   // DTMF symbol (i.e. key pressed)
src/noarch/Phone_impl.h 423)   else if (cmd == "dtmf") {
src/noarch/Phone_impl.h 424)     char key;
src/noarch/Phone_impl.h 425)     if (!parser.fixChr(':') || !parser.oneChrOf("0123456789*#", key))
src/noarch/Phone_impl.h 426)       return;
Stefan Schuermans phone connector module basi...

Stefan Schuermans authored 12 years ago

src/noarch/Phone_impl.h 427)     keyPressed(line, key);
Stefan Schuermans implemented extension confi...

Stefan Schuermans authored 12 years ago

src/noarch/Phone_impl.h 428)   }
Stefan Schuermans begin of phone connector

Stefan Schuermans authored 12 years ago

src/noarch/Phone_impl.h 429) }
src/noarch/Phone_impl.h 430) 
Stefan Schuermans phone connector module basi...

Stefan Schuermans authored 12 years ago

src/noarch/Phone_impl.h 431) /**
src/noarch/Phone_impl.h 432)  * @brief process incoming call
src/noarch/Phone_impl.h 433)  * @param[in] line number of phone line
src/noarch/Phone_impl.h 434)  * @param[in] extension extenstion called (i.e. phone number)
src/noarch/Phone_impl.h 435)  */
src/noarch/Phone_impl.h 436) template<typename ADDR, typename SOCK>
src/noarch/Phone_impl.h 437) void Phone<ADDR, SOCK>::incomingCall(unsigned int line,
src/noarch/Phone_impl.h 438)                                      const std::string &extension)
src/noarch/Phone_impl.h 439) {
src/noarch/Phone_impl.h 440)   // hangup old call on this line (to be on the safe side)
src/noarch/Phone_impl.h 441)   hangup(line);
src/noarch/Phone_impl.h 442) 
Stefan Schuermans clarified operator connecti...

Stefan Schuermans authored 12 years ago

src/noarch/Phone_impl.h 443)   // buffer further commands to be sent to this line until it is connected
src/noarch/Phone_impl.h 444)   // -> create command buffer for this line
src/noarch/Phone_impl.h 445)   m_cmdBufMap[line];
src/noarch/Phone_impl.h 446) 
Stefan Schuermans phone connector module basi...

Stefan Schuermans authored 12 years ago

src/noarch/Phone_impl.h 447)   // lookup extension
src/noarch/Phone_impl.h 448)   ExtMap::iterator itExt = m_extMap.find(extension);
src/noarch/Phone_impl.h 449)   if (itExt == m_extMap.end())
src/noarch/Phone_impl.h 450)     return; // unknown extension -> ignore
src/noarch/Phone_impl.h 451) 
src/noarch/Phone_impl.h 452)   // try to open operator connection to module
src/noarch/Phone_impl.h 453)   OpConn *pConn = m_mgrs.m_opMgr.connect(itExt->second, this);
src/noarch/Phone_impl.h 454)   if (!pConn) // module is not ready for connection
src/noarch/Phone_impl.h 455)     return;
src/noarch/Phone_impl.h 456) 
src/noarch/Phone_impl.h 457)   // add connection to maps
src/noarch/Phone_impl.h 458)   m_lineConnMap[line] = pConn;
src/noarch/Phone_impl.h 459)   m_connLineMap[pConn] = line;
Stefan Schuermans accepting EBIP calls works now

Stefan Schuermans authored 12 years ago

src/noarch/Phone_impl.h 460) 
src/noarch/Phone_impl.h 461)   // send accept message
src/noarch/Phone_impl.h 462)   sendAccept(line);
Stefan Schuermans phone connector module basi...

Stefan Schuermans authored 12 years ago

src/noarch/Phone_impl.h 463) }
src/noarch/Phone_impl.h 464) 
Stefan Schuermans clarified operator connecti...

Stefan Schuermans authored 12 years ago

src/noarch/Phone_impl.h 465) /**
src/noarch/Phone_impl.h 466)  * @brief phone line connected
src/noarch/Phone_impl.h 467)  * @param[in] line number of phone line
src/noarch/Phone_impl.h 468)  */
src/noarch/Phone_impl.h 469) template<typename ADDR, typename SOCK>
src/noarch/Phone_impl.h 470) void Phone<ADDR, SOCK>::connected(unsigned int line)
src/noarch/Phone_impl.h 471) {
src/noarch/Phone_impl.h 472)   // get buffered commands for this line
src/noarch/Phone_impl.h 473)   CmdBuf &cmdBuf = m_cmdBufMap[line];
src/noarch/Phone_impl.h 474) 
src/noarch/Phone_impl.h 475)   // send buffered commands now
src/noarch/Phone_impl.h 476)   for (CmdBuf::const_iterator cmd = cmdBuf.begin();
src/noarch/Phone_impl.h 477)        cmd != cmdBuf.end(); ++cmd) {
src/noarch/Phone_impl.h 478)     std::stringstream strm;
src/noarch/Phone_impl.h 479)     strm << line << ":" << *cmd;
src/noarch/Phone_impl.h 480)     sendSock(strm.str());
src/noarch/Phone_impl.h 481)   }
src/noarch/Phone_impl.h 482) 
src/noarch/Phone_impl.h 483)   // delete command buffer for this line
src/noarch/Phone_impl.h 484)   m_cmdBufMap.erase(line);
src/noarch/Phone_impl.h 485) }
src/noarch/Phone_impl.h 486) 
Stefan Schuermans phone connector module basi...

Stefan Schuermans authored 12 years ago

src/noarch/Phone_impl.h 487) /**
src/noarch/Phone_impl.h 488)  * @brief hangup on phone line
src/noarch/Phone_impl.h 489)  * @param[in] line number of phone line
src/noarch/Phone_impl.h 490)  */
src/noarch/Phone_impl.h 491) template<typename ADDR, typename SOCK>
src/noarch/Phone_impl.h 492) void Phone<ADDR, SOCK>::hangup(unsigned int line)
src/noarch/Phone_impl.h 493) {
src/noarch/Phone_impl.h 494)   // get connection
Stefan Schuermans implemented play and key me...

Stefan Schuermans authored 12 years ago

src/noarch/Phone_impl.h 495)   OpConn *pConn;
src/noarch/Phone_impl.h 496)   if (!line2conn(line, pConn))
Stefan Schuermans phone connector module basi...

Stefan Schuermans authored 12 years ago

src/noarch/Phone_impl.h 497)     return; // no connection on this line
src/noarch/Phone_impl.h 498) 
src/noarch/Phone_impl.h 499)   // close connection
src/noarch/Phone_impl.h 500)   pConn->close();
src/noarch/Phone_impl.h 501) 
src/noarch/Phone_impl.h 502)   // remove connection from maps
Stefan Schuermans implemented play and key me...

Stefan Schuermans authored 12 years ago

src/noarch/Phone_impl.h 503)   m_lineConnMap.erase(line);
Stefan Schuermans phone connector module basi...

Stefan Schuermans authored 12 years ago

src/noarch/Phone_impl.h 504)   m_connLineMap.erase(pConn);
Stefan Schuermans clarified operator connecti...

Stefan Schuermans authored 12 years ago

src/noarch/Phone_impl.h 505) 
src/noarch/Phone_impl.h 506)   // remove command buffer for this line
src/noarch/Phone_impl.h 507)   m_cmdBufMap.erase(line);
Stefan Schuermans phone connector module basi...

Stefan Schuermans authored 12 years ago

src/noarch/Phone_impl.h 508) }
src/noarch/Phone_impl.h 509) 
src/noarch/Phone_impl.h 510) /**
src/noarch/Phone_impl.h 511)  * @brief key pressed on phone line
src/noarch/Phone_impl.h 512)  * @param[in] line number of phone line
src/noarch/Phone_impl.h 513)  * @param[in] key key that has been pressed
src/noarch/Phone_impl.h 514)  */
src/noarch/Phone_impl.h 515) template<typename ADDR, typename SOCK>
src/noarch/Phone_impl.h 516) void Phone<ADDR, SOCK>::keyPressed(unsigned int line, char key)
src/noarch/Phone_impl.h 517) {
src/noarch/Phone_impl.h 518)   // get connection
Stefan Schuermans implemented play and key me...

Stefan Schuermans authored 12 years ago

src/noarch/Phone_impl.h 519)   OpConn *pConn;
src/noarch/Phone_impl.h 520)   if (!line2conn(line, pConn))
Stefan Schuermans phone connector module basi...

Stefan Schuermans authored 12 years ago

src/noarch/Phone_impl.h 521)     return; // no connection on this line
src/noarch/Phone_impl.h 522) 
Stefan Schuermans implemented play and key me...

Stefan Schuermans authored 12 years ago

src/noarch/Phone_impl.h 523)   // send key press event over connection
src/noarch/Phone_impl.h 524)   pConn->sendKey(key);
src/noarch/Phone_impl.h 525) }
src/noarch/Phone_impl.h 526) 
src/noarch/Phone_impl.h 527) /**
src/noarch/Phone_impl.h 528)  * @brief get phone line number from operator connection
src/noarch/Phone_impl.h 529)  * @param[in] pConn operator connection object
src/noarch/Phone_impl.h 530)  * @param[out] line phone line number
src/noarch/Phone_impl.h 531)  * @return if phone line was found
src/noarch/Phone_impl.h 532)  */
src/noarch/Phone_impl.h 533) template<typename ADDR, typename SOCK>
src/noarch/Phone_impl.h 534) bool Phone<ADDR, SOCK>::conn2line(OpConn *pConn, unsigned int &line) const
src/noarch/Phone_impl.h 535) {
src/noarch/Phone_impl.h 536)   ConnLineMap::const_iterator itConn = m_connLineMap.find(pConn);
src/noarch/Phone_impl.h 537)   if (itConn == m_connLineMap.end())
src/noarch/Phone_impl.h 538)     return false;
src/noarch/Phone_impl.h 539)   line = itConn->second;
src/noarch/Phone_impl.h 540)   return true;
src/noarch/Phone_impl.h 541) }
src/noarch/Phone_impl.h 542) 
src/noarch/Phone_impl.h 543) /**
src/noarch/Phone_impl.h 544)  * @brief get operator connection from phone line number
src/noarch/Phone_impl.h 545)  * @param[in] line phone line number
src/noarch/Phone_impl.h 546)  * @param[out] pConn operator connection object
src/noarch/Phone_impl.h 547)  * @return if phone line was found
src/noarch/Phone_impl.h 548)  */
src/noarch/Phone_impl.h 549) template<typename ADDR, typename SOCK>
src/noarch/Phone_impl.h 550) bool Phone<ADDR, SOCK>::line2conn(unsigned int line, OpConn *&pConn) const
src/noarch/Phone_impl.h 551) {
src/noarch/Phone_impl.h 552)   LineConnMap::const_iterator itLine = m_lineConnMap.find(line);
src/noarch/Phone_impl.h 553)   if (itLine == m_lineConnMap.end())
src/noarch/Phone_impl.h 554)     return false;
src/noarch/Phone_impl.h 555)   pConn = itLine->second;
src/noarch/Phone_impl.h 556)   return true;
Stefan Schuermans phone connector module basi...

Stefan Schuermans authored 12 years ago

src/noarch/Phone_impl.h 557) }
src/noarch/Phone_impl.h 558) 
Stefan Schuermans begin of phone connector

Stefan Schuermans authored 12 years ago

src/noarch/Phone_impl.h 559) /// update time callback
src/noarch/Phone_impl.h 560) template<typename ADDR, typename SOCK>
src/noarch/Phone_impl.h 561) void Phone<ADDR, SOCK>::updateTimeCallback()
src/noarch/Phone_impl.h 562) {
src/noarch/Phone_impl.h 563)   m_mgrs.m_callMgr.requestTimeCall(this, m_timeRegister < m_timeHeartbeat
src/noarch/Phone_impl.h 564)                                          ? m_timeRegister : m_timeHeartbeat);
src/noarch/Phone_impl.h 565) }
src/noarch/Phone_impl.h 566) 
src/noarch/Phone_impl.h 567) template<typename ADDR, typename SOCK>
BlinkenArea fix EBIP timeout and heartbeat

BlinkenArea authored 12 years ago

src/noarch/Phone_impl.h 568) const Time Phone<ADDR, SOCK>::m_serverTimeout(60);