b0VIM 7.3GR)stefansamson~stefan/Blinker/src/common/SyncReceiver_impl.hutf-8 3210#"! Utp*n,6ad *mML(wcN5 m Q , (  s T  j Z X W @  x J H ^ K 9 5 4 XT-~QM&geR@&pd`_N$|U(& c<   return; if (!m_pSock) // make sure socket exists std::cout << "DEBUG call" << std::endl; ADDR addr; std::string data;{void SyncReceiver::receiveFromSock()template/// receive data from socket} } m_pSock = NULL; delete m_pSock; if (m_pSock) { // destroy socket m_mgrs.m_callMgr.cancelIoReadCall(this, m_pSock); // cancel callback request{void SyncReceiver::destroySock()template/// destroy socket} m_mgrs.m_callMgr.requestIoReadCall(this, m_pSock); // request callback on recepetion } return; m_pSock = NULL; delete m_pSock; if (!m_pSock->bind(m_fileBind.m_obj)) { // bind socket } return; m_pSock = NULL; delete m_pSock; if (!m_fileBind.m_valid) { m_fileBind.update(); // get bind address from bind address setting file } return; if (!m_pSock) m_pSock = new SOCK(); if (!m_pSock) { // create socket{void SyncReceiver::createSock()template/// create socket and bind it} (void)io; // unused{void SyncReceiver::ioWriteCall(Io *io)template */ * @param[in] io I/O object that is writable * @brief callback when I/O object is writable/**} receiveFromSock(); if (io == m_pSock) // reception on socket{void SyncReceiver::ioReadCall(Io *io)template */ * @param[in] io I/O object that is readable * @brief callback when I/O object is readable/**} m_fileSrc.update(); if (m_fileSrc.checkModified()) // source address file was modified -> re-read source address } createSock(); destroySock(); if (m_fileBind.checkModified()) { // bind address file was modified -> re-create socket m_fileOutSync.update(); if (m_fileOutSync.checkModified()) // output sync stream name file was modified -> re-get output sync stream{void SyncReceiver::updateConfig()template/// check for update of configuration} destroySock(); // destroy socket{SyncReceiver::~SyncReceiver()template/// virtual destructor} createSock(); // create and bind socket std::cout << "DEBUG construct" << std::endl;{ m_pSock(NULL) m_fileSrc(dirBase.getFile("source")), m_fileBind(dirBase.getFile("bind")), m_fileOutSync(dirBase.getFile("outsync"), mgrs.m_syncMgr), Module(name, mgrs, dirBase), const Directory &dirBase):SyncReceiver::SyncReceiver(const std::string &name, Mgrs &mgrs,template */ * @param[in] dirBase base directory * @param[in] mgrs managers * @param[in] name module name * @brief constructor/**namespace Blinker {#include "SyncReceiver.h"#include "SyncRecv.h"#include "SettingFile.h"#include "ProtocolFile.h"#include "Protocol.h"#include "OutSyncFile.h"#include "NetHost.h"#include "Module.h"#include "Mgrs.h"#include "IoCallee.h"#include "File.h"#include "Directory.h"#include #include #include #define BLINKER_SYNCRECEIVER_IMPL_H#ifndef BLINKER_SYNCRECEIVER_IMPL_H a blinkenarea.org project */ Copyleft GNU public license - http://www.gnu.org/copyleft/gpl.html Copyright 2011-2014 Stefan Schuermans /* Blinkeradf Z 6M54_ Z  k f e L 5 4  q e )  [ Z 0 #endif // #ifndef BLINKER_SYNCRECEIVER_IMPL_H} // names#endif // #ifndef BLINKER_SYNCRECEIVER_IM#endif // #ifndef BLINKER_SYNCRECEIVER_IMPL_H} // namespace Blinker} m_fileOutSync.sendInfo(info); // pass on sync information info.pos_ms = Net2Host32(packet.pos_ms); info.name = packet.name; info.pause = (Net2Host32(packet.flags) & PoSyPause) != 0; return; if (memcmp(packet.magic, "PoSy", sizeof(packet.magic)) != 0) memcpy(&packet, data.c_str(), sizeof(packet)); return; if (data.size() < sizeof(packet)) // parse frame, leave if invalid SyncRecv::Info info; PoSyPacket packet; }; PoSyPause = 0x00000001, ///< pause mode active enum PoSyFlags { /// flags for PoSyPacket }; uint32_t pos_ms; ///< position within current piece in milliseconds char name[64]; ///< name of current piece in playlist uint32_t flags; ///< flags, see PosSyFlags below char magic[4]; ///< fixed magic, always "PoSy" struct PoSyPacket { /// Po.W.E.R. (stage play by BBM) synchronization protocol{void SyncReceiver::procInfo(const std::string &data)template */ * @param[in] data received synchronization data * @brief process synchronization information/**} procInfo(data); // process received synchronization information return; // mismatch if (m_fileSrc.m_valid && addr != m_fileSrc.m_obj) // check source address (if configured) return; if (!m_pSock->recv(data, addr)) // receive (leave if no reception)ad$nc97#F!  ~ >     w E C *  p = ; % # "  p ^ P L K  n Z F : 6 5  rpS US?21m= return; if (!m_pSock) // make sure socke return; if (!m_pSock) // make sure return; if (!m_pSock) // make sure socket exist return; if (!m_pSock) // make sure return; if (!m_pSock) // make sure socket exists ADDR addr; std::string data;{void SyncReceiver::receiveFromSock()template/// receive data from socket} } m_pSock = NULL; delete m_pSock; if (m_pSock) { // destroy socket m_mgrs.m_callMgr.cancelIoReadCall(this, m_pSock); // cancel callback request{void SyncReceiver::destroySock()template/// destroy socket} m_mgrs.m_callMgr.requestIoReadCall(this, m_pSock); // request callback on recepetion } return; m_pSock = NULL; delete m_pSock; if (!m_pSock->bind(m_fileBind.m_obj)) { // bind socket } return; m_pSock = NULL; delete m_pSock; if (!m_fileBind.m_valid) { m_fileBind.update(); // get bind address from bind address setting file } return; if (!m_pSock) m_pSock = new SOCK(); if (!m_pSock) { // create socket{void SyncReceiver::createSock()template/// create socket and bind it} (void)io; // unused{void SyncReceiver::ioWriteCall(Io *io)template */ * @param[in] io I/O object that is writable * @brief callback when I/O object is writable/**} receiveFromSock(); if (io == m_pSock) // reception on socket{void SyncReceiver::ioReadCall(Io *io)template */ * @param[in] io I/O object that is readable * @brief callback when I/O object is readable/**} m_fileSrc.update(); if (m_fileSrc.checkModified()) // source address file was modified -> re-read source address } createSock(); destroySock(); if (m_fileBind.checkModified()) { // bind address file was modified -> re-create socket m_fileOutSync.update(); if (m_fileOutSync.checkModified()) // output sync stream name file was modified -> re-get output sync stream{void SyncReceiver::updateConfig()template/// check for update of configuration} destroySock(); // destroy socket{SyncReceiver::~SyncReceiver()template/// virtual destructor} createSock(); // create and bind socket m_fileSrc.update(); // read source address