| Line | Branch | Exec | Source |
|---|---|---|---|
| 1 | # include "na64dp/processingInfoZMQ.hh" | ||
| 2 | |||
| 3 | # include <sstream> | ||
| 4 | # include <iostream> // xxx, for cerr | ||
| 5 | |||
| 6 | #if defined(ZMQ_FOUND) && ZMQ_FOUND | ||
| 7 | |||
| 8 | namespace na64dp { | ||
| 9 | |||
| 10 | static const char gEPITag[] = "epi:"; | ||
| 11 | |||
| 12 | ✗ | ZMQPubEventProcessingInfo::ZMQPubEventProcessingInfo( int portNo | |
| 13 | , size_t nMaxEvents | ||
| 14 | ✗ | , unsigned int refreshInterval) | |
| 15 | : EvProcInfoDispatcher( nMaxEvents, refreshInterval ) | ||
| 16 | ✗ | , _zCtx(1) | |
| 17 | ✗ | , _zPubSock(_zCtx, ZMQ_PUB) { | |
| 18 | ✗ | std::ostringstream oss; | |
| 19 | ✗ | oss << "tcp://*:" << portNo; | |
| 20 | ✗ | _zPubSock.bind( oss.str().c_str() ); | |
| 21 | } | ||
| 22 | |||
| 23 | // TODO: elaborate error reporting on 0MQ failures | ||
| 24 | void | ||
| 25 | ✗ | ZMQPubEventProcessingInfo::_update_event_processing_info() { | |
| 26 | ✗ | throw std::runtime_error("TODO: serialize and dispatch status"); // TODO | |
| 27 | // previously we had status serialized by means of capnp. Remnants of this | ||
| 28 | // method are still saved in the `processingInfo.cc` (excerpt() method) | ||
| 29 | #if 0 | ||
| 30 | // Get the short description of ongoing processing | ||
| 31 | excerpt(_msgBuf); | ||
| 32 | assert( _msgBuf.size() ); | ||
| 33 | |||
| 34 | // Prefix network message with 'EPS ' indicating that it is event | ||
| 35 | // processing info data (to be filtered by subscribers) | ||
| 36 | { | ||
| 37 | if( ! _zPubSock.send( gEPITag, sizeof(gEPITag) - 1, ZMQ_SNDMORE ) ) { | ||
| 38 | std::cerr << "Failed to send 0MQ msg prefix." << std::endl; | ||
| 39 | } | ||
| 40 | zmq::message_t message( _msgBuf.size() ); | ||
| 41 | memcpy( message.data() | ||
| 42 | , _msgBuf.data() | ||
| 43 | , _msgBuf.size() ); | ||
| 44 | if( ! _zPubSock.send( message, 0x0 ) ) { | ||
| 45 | std::cerr << "Failed to send zmq msg" << std::endl; | ||
| 46 | } | ||
| 47 | } | ||
| 48 | |||
| 49 | _msgBuf.clear(); | ||
| 50 | #endif | ||
| 51 | } | ||
| 52 | |||
| 53 | } // namespace na64dp | ||
| 54 | |||
| 55 | # endif | ||
| 56 | |||
| 57 |