NAME

POEx::ZMQ3::Publisher - A PUB-type ZeroMQ socket

SYNOPSIS

use POE;

my $zpub = POEx::ZMQ3::Publisher->new();

POE::Session->create(
  inline_states => {

    _start => sub {
      ## Bind our Publisher to some endpoints:
      $zsub->start(
        'tcp://127.0.0.1:5665',
        'tcp://127.0.0.1:1234',
      );

      ## Our session wants all emitted events:
      $_[KERNEL]->post( $zsub->session_id,
        'subscribe',
        'all'
      );

      ## Push messages on a timer loop forever:
      $_[KERNEL]->delay( push_messages => 1 );
    },

    zeromq_publishing_on => sub {
      my $endpoint = $_[ARG0];
      print "Publishing on $endpoint\n";
    },

    push_messages => sub {
      $zsub->publish(
        'This is data \o/'
      );

      $_[KERNEL]->delay( push_messages => 1 );
    },
  }
);

$poe_kernel->run;

DESCRIPTION

A lightweight ZeroMQ publisher-type socket using POEx::ZMQ3::Role::Emitter.

Methods

start

$zsub->start( @publish_on );

Start the Publisher and bind some endpoint(s).

stop

$zsub->stop;

Stop the Publisher, closing out the socket and stopping the event emitter.

publish

$zsub->publish( @data );

Publish some item(s) to the ZeroMQ socket.

This base class does no special serialization on its own.

Events

zeromq_publishing_on

Emitted when we are initialized; $_[ARG0] is the endpoint we are publishing on.

SEE ALSO

POEx::ZMQ3

POEx::ZMQ3::Subscriber

ZMQ::LibZMQ3

http://www.zeromq.org

AUTHOR

Jon Portnoy <avenj@cobaltirc.org>