ZeroMQ::PubSub::Client - Connect to a PubSub server to send and receive events
use ZeroMQ::PubSub::Client; use Time::HiRes; my $client = ZeroMQ::PubSub::Client->new( publish_address => 'tcp://127.0.0.1:4000', subscribe_address => 'tcp://127.0.0.1:5000', debug => 1, ); my $ping_start_time; # called when we receive our ping back $client->subscribe(ping => sub { # print round-trip latency my ($self, $params) = @_; print "Ping: " . (Time::HiRes::time() - $ping_start_time) . "s.\n"; }); # publish ping event $ping_start_time = Time::HiRes::time(); $client->publish( ping => { 'time' => $ping_time } ); # wait to receive our ping $client->poll_once;
Address of event publishing socket. Must be in the form of transport://addr. See https://metacpan.org/module/ZeroMQ::Socket#bind
transport://addr
Address of socket to receive events from. See above.
Connects to the subscription socket on the server. Automatically called by subscribe() and poll_once().
subscribe()
poll_once()
Blocks and waits for an event. Dispatches to event callbacks.
Publishes $event to all subscribers on the server. This will block while attempting to connect.
ZeroMQ::PubSub::Server, ZeroMQ::PubSub
To install ZeroMQ::PubSub, copy and paste the appropriate command in to your terminal.
cpanm
cpanm ZeroMQ::PubSub
CPAN shell
perl -MCPAN -e shell install ZeroMQ::PubSub
For more information on module installation, please visit the detailed CPAN module installation guide.