From 85cbd7f83c10c70da8fa44fe7673143703f9710d Mon Sep 17 00:00:00 2001 From: malosek Date: Tue, 22 Sep 2009 15:12:51 +0200 Subject: added PGM bus functionality --- src/pgm_receiver.hpp | 37 ++++++++++++++++++++++++------------- 1 file changed, 24 insertions(+), 13 deletions(-) (limited to 'src/pgm_receiver.hpp') diff --git a/src/pgm_receiver.hpp b/src/pgm_receiver.hpp index 05b27e2..b573081 100644 --- a/src/pgm_receiver.hpp +++ b/src/pgm_receiver.hpp @@ -30,6 +30,8 @@ #include "zmq_decoder.hpp" #include "pgm_socket.hpp" +#include + namespace zmq { @@ -45,7 +47,6 @@ namespace zmq ~pgm_receiver_t (); int init (bool udp_encapsulation_, const char *network_); - void reconnect (); // i_engine interface implementation. void plug (struct i_inout *inout_); @@ -57,15 +58,28 @@ namespace zmq void out_event (); private: - // Read exactly iov_len_ count APDUs, function returns number - // of bytes received. Note that if we did not join message stream - // before and there is not message beginning in the APDUs being - // received iov_len for such a APDUs will be 0. - ssize_t receive_with_offset (void **data_); - - // Message decoder. - zmq_decoder_t *decoder; - + + // Map to hold TSI, joined and decoder for each peer. + struct peer_info_t { + bool joined; + zmq_decoder_t *decoder; + }; + + struct tsi_comp { + bool operator () (const pgm_tsi_t <si, const pgm_tsi_t &rtsi) const + { + if (ltsi.sport < rtsi.sport) + return true; + + return (std::lexicographical_compare (ltsi.gsi.identifier, + ltsi.gsi.identifier + 6, + rtsi.gsi.identifier, rtsi.gsi.identifier + 6)); + } + }; + + typedef std::map peer_t; + peer_t peers; + // PGM socket. pgm_socket_t pgm_socket; @@ -75,9 +89,6 @@ namespace zmq // Name of the session associated with the connecter. std::string session_name; - // If receiver joined the messages stream. - bool joined; - // Parent session. i_inout *inout; -- cgit v1.2.3