f670ca05dd608c9d5b0300ca1dc493f6ffd8afa1
Stefan Schuermans implement operator connecti...

Stefan Schuermans authored 12 years ago

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

Stefan Schuermans authored 10 years ago

src/noarch/OpPrinter.cpp   2)    Copyright 2011-2014 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) {
src/noarch/OpPrinter.cpp 106)     case '7': pConn->sendPlay("ueber_7_bruecken"); break;
src/noarch/OpPrinter.cpp 107)     case '9': pConn->sendPlay("99_luftballons"); break;
Stefan Schuermans OpPrinter: play sound on co...

Stefan Schuermans authored 12 years ago

src/noarch/OpPrinter.cpp 108)     case '#':
src/noarch/OpPrinter.cpp 109)       std::cout << "closing connection " << pConn << std::endl;
src/noarch/OpPrinter.cpp 110)       pConn->close();
src/noarch/OpPrinter.cpp 111)       m_opConns.erase(pConn);
src/noarch/OpPrinter.cpp 112)       m_sendPlay.erase(pConn); // could be in there, better be on safe side
src/noarch/OpPrinter.cpp 113)       break;
Stefan Schuermans implemented play and key me...

Stefan Schuermans authored 12 years ago

src/noarch/OpPrinter.cpp 114)   }
src/noarch/OpPrinter.cpp 115) }
src/noarch/OpPrinter.cpp 116) 
src/noarch/OpPrinter.cpp 117) /**
src/noarch/OpPrinter.cpp 118)  * @brief play command received on operator connection
src/noarch/OpPrinter.cpp 119)  * @param[in] pConn operator connection object
src/noarch/OpPrinter.cpp 120)  * @param[in] sound name of sound to play
src/noarch/OpPrinter.cpp 121)  */
src/noarch/OpPrinter.cpp 122) void OpPrinter::opConnRecvPlay(OpConn *pConn, const std::string &sound)
src/noarch/OpPrinter.cpp 123) {
src/noarch/OpPrinter.cpp 124)   // this interface is usually not called for incoming connections
src/noarch/OpPrinter.cpp 125)   std::cout << "play sound \"" << sound << "\" on connection " << pConn
src/noarch/OpPrinter.cpp 126)             << std::endl;
src/noarch/OpPrinter.cpp 127) }
src/noarch/OpPrinter.cpp 128) 
Stefan Schuermans implement operator connecti...

Stefan Schuermans authored 12 years ago

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

Stefan Schuermans authored 12 years ago

src/noarch/OpPrinter.cpp 132)  *
src/noarch/OpPrinter.cpp 133)  * 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 134)  */
src/noarch/OpPrinter.cpp 135) void OpPrinter::opConnClose(OpConn *pConn)
src/noarch/OpPrinter.cpp 136) {
src/noarch/OpPrinter.cpp 137)   std::cout << "connection " << pConn << " closed" << std::endl;
Stefan Schuermans fix operator connection pri...

Stefan Schuermans authored 12 years ago

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

Stefan Schuermans authored 12 years ago

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