362c1f4c3b5ce9e3fce11167a51fbe4cdb2174de
Stefan Schuermans implement operator connecti...

Stefan Schuermans authored 12 years ago

src/noarch/OpPrinter.cpp   1) /* Blinker
Stefan Schuermans update copyright header

Stefan Schuermans authored 5 years ago

src/common/OpPrinter.cpp   2)    Copyright 2011-2019 Stefan Schuermans <stefan@blinkenarea.org>
Stefan Schuermans implement operator connecti...

Stefan Schuermans authored 12 years ago

src/noarch/OpPrinter.cpp   3)    Copyleft GNU public license - http://www.gnu.org/copyleft/gpl.html
src/noarch/OpPrinter.cpp   4)    a blinkenarea.org project */
src/noarch/OpPrinter.cpp   5) 
src/noarch/OpPrinter.cpp   6) #include <iostream>
src/noarch/OpPrinter.cpp   7) #include <string>
src/noarch/OpPrinter.cpp   8) 
Stefan Schuermans OpPrinter: play sound on co...

Stefan Schuermans authored 12 years ago

src/noarch/OpPrinter.cpp   9) #include "CallMgr.h"
Stefan Schuermans implement operator connecti...

Stefan Schuermans authored 12 years ago

src/noarch/OpPrinter.cpp  10) #include "Directory.h"
src/noarch/OpPrinter.cpp  11) #include "File.h"
src/noarch/OpPrinter.cpp  12) #include "Mgrs.h"
src/noarch/OpPrinter.cpp  13) #include "Module.h"
src/noarch/OpPrinter.cpp  14) #include "OpConn.h"
src/noarch/OpPrinter.cpp  15) #include "OpConnIf.h"
src/noarch/OpPrinter.cpp  16) #include "OpMgr.h"
src/noarch/OpPrinter.cpp  17) #include "OpPrinter.h"
src/noarch/OpPrinter.cpp  18) #include "OpReqIf.h"
Stefan Schuermans OpPrinter: play sound on co...

Stefan Schuermans authored 12 years ago

src/noarch/OpPrinter.cpp  19) #include "Time.h"
src/noarch/OpPrinter.cpp  20) #include "TimeCallee.h"
Stefan Schuermans implement operator connecti...

Stefan Schuermans authored 12 years ago

src/noarch/OpPrinter.cpp  21) 
src/noarch/OpPrinter.cpp  22) namespace Blinker {
src/noarch/OpPrinter.cpp  23) 
src/noarch/OpPrinter.cpp  24) /**
src/noarch/OpPrinter.cpp  25)  * @brief constructor
Stefan Schuermans make modules know their name

Stefan Schuermans authored 12 years ago

src/noarch/OpPrinter.cpp  26)  * @param[in] name module name
Stefan Schuermans implement operator connecti...

Stefan Schuermans authored 12 years ago

src/noarch/OpPrinter.cpp  27)  * @param[in] mgrs managers
src/noarch/OpPrinter.cpp  28)  * @param[in] dirBase base directory
src/noarch/OpPrinter.cpp  29)  */
Stefan Schuermans make modules know their name

Stefan Schuermans authored 12 years ago

src/noarch/OpPrinter.cpp  30) OpPrinter::OpPrinter(const std::string &name, Mgrs &mgrs,
src/noarch/OpPrinter.cpp  31)                      const Directory &dirBase):
src/noarch/OpPrinter.cpp  32)   Module(name, mgrs, dirBase)
Stefan Schuermans implement operator connecti...

Stefan Schuermans authored 12 years ago

src/noarch/OpPrinter.cpp  33) {
Stefan Schuermans fix operator connection pri...

Stefan Schuermans authored 12 years ago

src/noarch/OpPrinter.cpp  34)   // open operator connection interface
Stefan Schuermans accepting EBIP calls works now

Stefan Schuermans authored 12 years ago

src/noarch/OpPrinter.cpp  35)   m_mgrs.m_opMgr.open(m_name, this);
Stefan Schuermans implement operator connecti...

Stefan Schuermans authored 12 years ago

src/noarch/OpPrinter.cpp  36) }
src/noarch/OpPrinter.cpp  37) 
src/noarch/OpPrinter.cpp  38) /// virtual destructor
src/noarch/OpPrinter.cpp  39) OpPrinter::~OpPrinter()
src/noarch/OpPrinter.cpp  40) {
Stefan Schuermans fix operator connection pri...

Stefan Schuermans authored 12 years ago

src/noarch/OpPrinter.cpp  41)   // close operator connection interface
Stefan Schuermans accepting EBIP calls works now

Stefan Schuermans authored 12 years ago

src/noarch/OpPrinter.cpp  42)   m_mgrs.m_opMgr.close(m_name);
Stefan Schuermans fix operator connection pri...

Stefan Schuermans authored 12 years ago

src/noarch/OpPrinter.cpp  43) 
src/noarch/OpPrinter.cpp  44)   // close open operator connections
src/noarch/OpPrinter.cpp  45)   while (!m_opConns.empty()) {
src/noarch/OpPrinter.cpp  46)     OpConns::iterator itOpConn = m_opConns.begin();
src/noarch/OpPrinter.cpp  47)     (*itOpConn)->close();
src/noarch/OpPrinter.cpp  48)     m_opConns.erase(itOpConn);
src/noarch/OpPrinter.cpp  49)   }
Stefan Schuermans implement operator connecti...

Stefan Schuermans authored 12 years ago

src/noarch/OpPrinter.cpp  50) }
src/noarch/OpPrinter.cpp  51) 
src/noarch/OpPrinter.cpp  52) /// check for update of configuration
src/noarch/OpPrinter.cpp  53) void OpPrinter::updateConfig()
src/noarch/OpPrinter.cpp  54) {
src/noarch/OpPrinter.cpp  55)   // nothing to do here for this module
src/noarch/OpPrinter.cpp  56) }
src/noarch/OpPrinter.cpp  57) 
Stefan Schuermans OpPrinter: play sound on co...

Stefan Schuermans authored 12 years ago

src/noarch/OpPrinter.cpp  58) /// callback when requested time reached
src/noarch/OpPrinter.cpp  59) void OpPrinter::timeCall()
src/noarch/OpPrinter.cpp  60) {
src/noarch/OpPrinter.cpp  61)   while (!m_sendPlay.empty()) {
src/noarch/OpPrinter.cpp  62)     OpConns::iterator it = m_sendPlay.begin();
src/noarch/OpPrinter.cpp  63)     (*it)->sendPlay("opprinter");
src/noarch/OpPrinter.cpp  64)     m_sendPlay.erase(it);
src/noarch/OpPrinter.cpp  65)   }
src/noarch/OpPrinter.cpp  66) }
src/noarch/OpPrinter.cpp  67) 
Stefan Schuermans implement operator connecti...

Stefan Schuermans authored 12 years ago

src/noarch/OpPrinter.cpp  68) /**
src/noarch/OpPrinter.cpp  69)  * @brief check if accepting new operator connction is possible
src/noarch/OpPrinter.cpp  70)  * @param[in] name operator interface name
src/noarch/OpPrinter.cpp  71)  * @return if accepting new connection is possible
src/noarch/OpPrinter.cpp  72)  */
src/noarch/OpPrinter.cpp  73) bool OpPrinter::acceptNewOpConn(const std::string &name)
src/noarch/OpPrinter.cpp  74) {
src/noarch/OpPrinter.cpp  75)   return true; // accept all connections
src/noarch/OpPrinter.cpp  76)   (void)name; // unused
src/noarch/OpPrinter.cpp  77) }
src/noarch/OpPrinter.cpp  78) 
src/noarch/OpPrinter.cpp  79) /**
src/noarch/OpPrinter.cpp  80)  * @brief new operator connection
src/noarch/OpPrinter.cpp  81)  * @param[in] name operator interface name
src/noarch/OpPrinter.cpp  82)  * @param[in] pConn operator connection object
Stefan Schuermans clarified operator connecti...

Stefan Schuermans authored 12 years ago

src/noarch/OpPrinter.cpp  83)  *
src/noarch/OpPrinter.cpp  84)  * The new connection may not yet be used for sending inside this callback.
Stefan Schuermans implement operator connecti...

Stefan Schuermans authored 12 years ago

src/noarch/OpPrinter.cpp  85)  */
src/noarch/OpPrinter.cpp  86) void OpPrinter::newOpConn(const std::string &name, OpConn *pConn)
src/noarch/OpPrinter.cpp  87) {
Stefan Schuermans fix operator connection pri...

Stefan Schuermans authored 12 years ago

src/noarch/OpPrinter.cpp  88)   m_opConns.insert(pConn);
Stefan Schuermans implement operator connecti...

Stefan Schuermans authored 12 years ago

src/noarch/OpPrinter.cpp  89)   std::cout << "new connection " << pConn << std::endl;
Stefan Schuermans OpPrinter: play sound on co...

Stefan Schuermans authored 12 years ago

src/noarch/OpPrinter.cpp  90)   m_sendPlay.insert(pConn); // schedule sending play command
src/noarch/OpPrinter.cpp  91)   m_mgrs.m_callMgr.requestTimeCall(this, Time::now());
Stefan Schuermans implement operator connecti...

Stefan Schuermans authored 12 years ago

src/noarch/OpPrinter.cpp  92)   (void)name; // unused
src/noarch/OpPrinter.cpp  93) }
src/noarch/OpPrinter.cpp  94) 
Stefan Schuermans implemented play and key me...

Stefan Schuermans authored 12 years ago

src/noarch/OpPrinter.cpp  95) /**
src/noarch/OpPrinter.cpp  96)  * @brief key command received on operator connection
src/noarch/OpPrinter.cpp  97)  * @param[in] pConn operator connection object
src/noarch/OpPrinter.cpp  98)  * @param[in] key key that was pressed
src/noarch/OpPrinter.cpp  99)  */
src/noarch/OpPrinter.cpp 100) void OpPrinter::opConnRecvKey(OpConn *pConn, char key)
src/noarch/OpPrinter.cpp 101) {
src/noarch/OpPrinter.cpp 102)   std::cout << "key \"" << key << "\" on connection " << pConn << std::endl;
src/noarch/OpPrinter.cpp 103) 
src/noarch/OpPrinter.cpp 104)   // reply to some keys with play command for sounds
src/noarch/OpPrinter.cpp 105)   switch (key) {
Stefan Schuermans sounds for each key in oppr...

Stefan Schuermans authored 5 years ago

src/common/OpPrinter.cpp 106)     case '0': pConn->sendPlay("zero"); break;
src/common/OpPrinter.cpp 107)     case '1': pConn->sendPlay("one"); break;
src/common/OpPrinter.cpp 108)     case '2': pConn->sendPlay("two"); break;
src/common/OpPrinter.cpp 109)     case '3': pConn->sendPlay("three"); break;
src/common/OpPrinter.cpp 110)     case '4': pConn->sendPlay("four"); break;
src/common/OpPrinter.cpp 111)     case '5': pConn->sendPlay("five"); break;
src/common/OpPrinter.cpp 112)     case '6': pConn->sendPlay("six"); break;
src/common/OpPrinter.cpp 113)     case '7': pConn->sendPlay("seven"); break;
src/common/OpPrinter.cpp 114)     case '8': pConn->sendPlay("eight"); break;
src/common/OpPrinter.cpp 115)     case '9': pConn->sendPlay("nine"); break;
src/common/OpPrinter.cpp 116)     case '*': pConn->sendPlay("star"); break;
Stefan Schuermans OpPrinter: play sound on co...

Stefan Schuermans authored 12 years ago

src/noarch/OpPrinter.cpp 117)     case '#':
src/noarch/OpPrinter.cpp 118)       std::cout << "closing connection " << pConn << std::endl;
src/noarch/OpPrinter.cpp 119)       pConn->close();
src/noarch/OpPrinter.cpp 120)       m_opConns.erase(pConn);
src/noarch/OpPrinter.cpp 121)       m_sendPlay.erase(pConn); // could be in there, better be on safe side
src/noarch/OpPrinter.cpp 122)       break;
Stefan Schuermans implemented play and key me...

Stefan Schuermans authored 12 years ago

src/noarch/OpPrinter.cpp 123)   }
src/noarch/OpPrinter.cpp 124) }
src/noarch/OpPrinter.cpp 125) 
src/noarch/OpPrinter.cpp 126) /**
src/noarch/OpPrinter.cpp 127)  * @brief play command received on operator connection
src/noarch/OpPrinter.cpp 128)  * @param[in] pConn operator connection object
src/noarch/OpPrinter.cpp 129)  * @param[in] sound name of sound to play
src/noarch/OpPrinter.cpp 130)  */
src/noarch/OpPrinter.cpp 131) void OpPrinter::opConnRecvPlay(OpConn *pConn, const std::string &sound)
src/noarch/OpPrinter.cpp 132) {
src/noarch/OpPrinter.cpp 133)   // this interface is usually not called for incoming connections
src/noarch/OpPrinter.cpp 134)   std::cout << "play sound \"" << sound << "\" on connection " << pConn
src/noarch/OpPrinter.cpp 135)             << std::endl;
src/noarch/OpPrinter.cpp 136) }
src/noarch/OpPrinter.cpp 137) 
Stefan Schuermans implement operator connecti...

Stefan Schuermans authored 12 years ago

src/noarch/OpPrinter.cpp 138) /**
src/noarch/OpPrinter.cpp 139)  * @brief operator connection is closed
src/noarch/OpPrinter.cpp 140)  * @param[in] pConn operator connection object
Stefan Schuermans clarified operator connecti...

Stefan Schuermans authored 12 years ago

src/noarch/OpPrinter.cpp 141)  *
src/noarch/OpPrinter.cpp 142)  * The connection may not be used for sending any more in this callback.
Stefan Schuermans implement operator connecti...

Stefan Schuermans authored 12 years ago

src/noarch/OpPrinter.cpp 143)  */
src/noarch/OpPrinter.cpp 144) void OpPrinter::opConnClose(OpConn *pConn)
src/noarch/OpPrinter.cpp 145) {
src/noarch/OpPrinter.cpp 146)   std::cout << "connection " << pConn << " closed" << std::endl;
Stefan Schuermans fix operator connection pri...

Stefan Schuermans authored 12 years ago

src/noarch/OpPrinter.cpp 147)   m_opConns.erase(pConn);
Stefan Schuermans OpPrinter: play sound on co...

Stefan Schuermans authored 12 years ago

src/noarch/OpPrinter.cpp 148)   m_sendPlay.erase(pConn); // could be in there, better be on safe side