2009-09-11 17:58:37 +02:00
|
|
|
/*
|
2013-03-12 13:17:00 +01:00
|
|
|
Copyright (c) 2007-2013 Contributors as noted in the AUTHORS file
|
2009-09-11 17:58:37 +02:00
|
|
|
|
|
|
|
This file is part of 0MQ.
|
|
|
|
|
|
|
|
0MQ is free software; you can redistribute it and/or modify it under
|
2010-10-30 15:08:28 +02:00
|
|
|
the terms of the GNU Lesser General Public License as published by
|
2009-09-11 17:58:37 +02:00
|
|
|
the Free Software Foundation; either version 3 of the License, or
|
|
|
|
(at your option) any later version.
|
|
|
|
|
|
|
|
0MQ is distributed in the hope that it will be useful,
|
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
2010-10-30 15:08:28 +02:00
|
|
|
GNU Lesser General Public License for more details.
|
2009-09-11 17:58:37 +02:00
|
|
|
|
2010-10-30 15:08:28 +02:00
|
|
|
You should have received a copy of the GNU Lesser General Public License
|
2009-09-11 17:58:37 +02:00
|
|
|
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
*/
|
|
|
|
|
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
|
|
|
|
|
|
|
#include "platform.hpp"
|
|
|
|
|
2009-09-24 16:23:49 +02:00
|
|
|
#if defined ZMQ_HAVE_OPENPGM
|
2009-09-11 17:58:37 +02:00
|
|
|
|
2009-10-06 12:57:24 +02:00
|
|
|
#ifdef ZMQ_HAVE_WINDOWS
|
|
|
|
#include "windows.hpp"
|
|
|
|
#endif
|
|
|
|
|
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
|
|
|
class pgm_sender_t : public io_object_t, public i_engine
|
|
|
|
{
|
|
|
|
|
|
|
|
public:
|
2009-12-28 11:51:06 +01:00
|
|
|
|
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 ();
|
|
|
|
|
2009-09-16 15:36:38 +02:00
|
|
|
int init (bool udp_encapsulation_, const char *network_);
|
2009-09-11 17:58:37 +02:00
|
|
|
|
|
|
|
// i_engine interface implementation.
|
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 ();
|
|
|
|
void activate_in ();
|
|
|
|
void activate_out ();
|
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);
|
2009-09-11 17:58:37 +02:00
|
|
|
|
|
|
|
private:
|
|
|
|
|
2012-05-27 15:15:09 +02:00
|
|
|
// Unplug the engine from the session.
|
|
|
|
void unplug ();
|
|
|
|
|
2010-09-28 22:46:56 +02:00
|
|
|
// TX and RX timeout timer ID's.
|
|
|
|
enum {tx_timer_id = 0xa0, rx_timer_id = 0xa1};
|
|
|
|
|
|
|
|
// Timers are running.
|
2010-10-15 10:58:19 +02:00
|
|
|
bool has_tx_timer;
|
|
|
|
bool has_rx_timer;
|
2010-09-28 22:46:56 +02:00
|
|
|
|
2013-03-18 02:00:00 +01:00
|
|
|
session_base_t *session;
|
|
|
|
|
2009-09-11 17:58:37 +02:00
|
|
|
// Message encoder.
|
2013-03-18 02:05:51 +01:00
|
|
|
v1_encoder_t encoder;
|
2009-09-11 17:58:37 +02:00
|
|
|
|
2013-03-18 02:00:00 +01:00
|
|
|
msg_t msg;
|
|
|
|
|
|
|
|
// Keeps track of message boundaries.
|
|
|
|
bool more_flag;
|
|
|
|
|
2009-09-11 17:58:37 +02:00
|
|
|
// PGM socket.
|
|
|
|
pgm_socket_t pgm_socket;
|
|
|
|
|
|
|
|
// Socket options.
|
|
|
|
options_t options;
|
|
|
|
|
|
|
|
// 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;
|
2009-09-11 17:58:37 +02:00
|
|
|
|
|
|
|
// Output buffer from pgm_socket.
|
|
|
|
unsigned char *out_buffer;
|
|
|
|
|
|
|
|
// Output buffer size.
|
|
|
|
size_t out_buffer_size;
|
|
|
|
|
2009-12-28 11:51:06 +01:00
|
|
|
// Number of bytes in the buffer to be written to the socket.
|
|
|
|
// If zero, there are no data to be sent.
|
2009-09-11 17:58:37 +02:00
|
|
|
size_t write_size;
|
|
|
|
|
|
|
|
pgm_sender_t (const pgm_sender_t&);
|
2011-01-13 11:44:23 +01:00
|
|
|
const pgm_sender_t &operator = (const pgm_sender_t&);
|
2009-09-11 17:58:37 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#endif
|