2023-06-05 00:16:05 +01:00
|
|
|
/* SPDX-License-Identifier: MPL-2.0 */
|
2009-09-11 17:58:37 +02:00
|
|
|
|
2009-09-15 09:57:11 +02:00
|
|
|
#ifndef __ZMQ_PGM_SENDER_HPP_INCLUDED__
|
|
|
|
#define __ZMQ_PGM_SENDER_HPP_INCLUDED__
|
2009-09-11 17:58:37 +02:00
|
|
|
|
2009-09-24 16:23:49 +02:00
|
|
|
#if defined ZMQ_HAVE_OPENPGM
|
2009-09-11 17:58:37 +02:00
|
|
|
|
|
|
|
#include "stdint.hpp"
|
|
|
|
#include "io_object.hpp"
|
|
|
|
#include "i_engine.hpp"
|
|
|
|
#include "options.hpp"
|
|
|
|
#include "pgm_socket.hpp"
|
2013-03-18 02:05:51 +01:00
|
|
|
#include "v1_encoder.hpp"
|
2013-03-18 02:00:00 +01:00
|
|
|
#include "msg.hpp"
|
2009-09-11 17:58:37 +02:00
|
|
|
|
|
|
|
namespace zmq
|
|
|
|
{
|
2011-11-09 15:22:20 +01:00
|
|
|
class io_thread_t;
|
|
|
|
class session_base_t;
|
2009-09-11 17:58:37 +02:00
|
|
|
|
2019-12-24 10:39:26 +01:00
|
|
|
class pgm_sender_t ZMQ_FINAL : public io_object_t, public i_engine
|
2018-02-01 11:46:09 +01:00
|
|
|
{
|
|
|
|
public:
|
2011-11-09 15:22:20 +01:00
|
|
|
pgm_sender_t (zmq::io_thread_t *parent_, const options_t &options_);
|
2009-09-11 17:58:37 +02:00
|
|
|
~pgm_sender_t ();
|
2018-02-01 11:46:09 +01:00
|
|
|
|
2009-09-16 15:36:38 +02:00
|
|
|
int init (bool udp_encapsulation_, const char *network_);
|
2018-02-01 11:46:09 +01:00
|
|
|
|
2009-09-11 17:58:37 +02:00
|
|
|
// i_engine interface implementation.
|
2020-05-13 17:32:06 +03:00
|
|
|
bool has_handshake_stage () { return false; };
|
2011-11-09 15:22:20 +01:00
|
|
|
void plug (zmq::io_thread_t *io_thread_, zmq::session_base_t *session_);
|
2010-08-14 08:37:38 +02:00
|
|
|
void terminate ();
|
2018-08-09 13:17:21 +02:00
|
|
|
bool restart_input ();
|
2013-09-26 09:37:04 +02:00
|
|
|
void restart_output ();
|
2013-06-06 13:13:10 +02:00
|
|
|
void zap_msg_available () {}
|
2019-02-01 05:43:45 -05:00
|
|
|
const endpoint_uri_pair_t &get_endpoint () const;
|
2018-02-01 11:46:09 +01:00
|
|
|
|
2009-09-11 17:58:37 +02:00
|
|
|
// i_poll_events interface implementation.
|
|
|
|
void in_event ();
|
|
|
|
void out_event ();
|
2010-09-28 22:46:56 +02:00
|
|
|
void timer_event (int token);
|
2018-02-01 11:46:09 +01:00
|
|
|
|
|
|
|
private:
|
2012-05-27 15:15:09 +02:00
|
|
|
// Unplug the engine from the session.
|
|
|
|
void unplug ();
|
2018-02-01 11:46:09 +01:00
|
|
|
|
2010-09-28 22:46:56 +02:00
|
|
|
// TX and RX timeout timer ID's.
|
2018-02-01 11:46:09 +01:00
|
|
|
enum
|
2009-09-11 17:58:37 +02:00
|
|
|
{
|
2010-09-28 22:46:56 +02:00
|
|
|
tx_timer_id = 0xa0,
|
|
|
|
rx_timer_id = 0xa1
|
2018-02-01 11:46:09 +01:00
|
|
|
};
|
2009-09-11 17:58:37 +02:00
|
|
|
|
2019-02-01 05:43:45 -05:00
|
|
|
const endpoint_uri_pair_t _empty_endpoint;
|
|
|
|
|
2009-09-11 17:58:37 +02:00
|
|
|
// Timers are running.
|
2010-09-28 22:46:56 +02:00
|
|
|
bool has_tx_timer;
|
2010-10-15 10:58:19 +02:00
|
|
|
bool has_rx_timer;
|
2013-03-18 02:00:00 +01:00
|
|
|
|
2013-03-18 02:05:51 +01:00
|
|
|
session_base_t *session;
|
2009-09-11 17:58:37 +02:00
|
|
|
|
2013-03-18 02:00:00 +01:00
|
|
|
// Message encoder.
|
|
|
|
v1_encoder_t encoder;
|
|
|
|
|
|
|
|
msg_t msg;
|
|
|
|
|
2009-09-11 17:58:37 +02:00
|
|
|
// Keeps track of message boundaries.
|
|
|
|
bool more_flag;
|
|
|
|
|
|
|
|
// PGM socket.
|
|
|
|
pgm_socket_t pgm_socket;
|
|
|
|
|
|
|
|
// Socket options.
|
2009-09-28 18:06:06 +02:00
|
|
|
options_t options;
|
2009-09-11 17:58:37 +02:00
|
|
|
|
|
|
|
// Poll handle associated with PGM socket.
|
|
|
|
handle_t handle;
|
|
|
|
handle_t uplink_handle;
|
2009-09-28 18:06:06 +02:00
|
|
|
handle_t rdata_notify_handle;
|
2010-01-05 11:22:14 +01:00
|
|
|
handle_t pending_notify_handle;
|
2016-04-25 12:18:46 +01:00
|
|
|
|
2009-09-11 17:58:37 +02:00
|
|
|
// Output buffer from pgm_socket.
|
|
|
|
unsigned char *out_buffer;
|
|
|
|
|
2009-12-28 11:51:06 +01:00
|
|
|
// Output buffer size.
|
2009-09-11 17:58:37 +02:00
|
|
|
size_t out_buffer_size;
|
|
|
|
|
|
|
|
// Number of bytes in the buffer to be written to the socket.
|
2011-01-13 11:44:23 +01:00
|
|
|
// If zero, there are no data to be sent.
|
|
|
|
size_t write_size;
|
2009-09-11 17:58:37 +02:00
|
|
|
|
2019-12-08 19:22:04 +01:00
|
|
|
ZMQ_NON_COPYABLE_NOR_MOVABLE (pgm_sender_t)
|
2018-02-01 11:46:09 +01:00
|
|
|
};
|
2009-09-11 17:58:37 +02:00
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#endif
|