Skip to content
Snippets Groups Projects
Commit 52385368 authored by Gerhard Gonter's avatar Gerhard Gonter :speech_balloon:
Browse files

standalone mode: added help and POD section

parent 7537598a
No related branches found
No related tags found
No related merge requests found
......@@ -14,6 +14,12 @@ Connect to a fanout pub/sub server to receive and send messages
$fanout->subscribe('mychannel');
$fanout->announce('mychannel', 'test message');
=head1 STANDALONE MODE
Start fanout, subscribe to three channels and monitor these:
perl -MNet::fanout -e 'Net::fanout::main()' -- --PeerHost=fanout.example.org --PeerPort=1986 channel1 channel2 channel3
=cut
use strict;
......@@ -253,11 +259,22 @@ sub main
{
my $l= <STDIN>; chop($l);
my ($cmd, $channel, $msg)= split(' ', $l, 3);
if ($cmd eq 'announce') { $fanout->announce($channel, $msg); }
if ($cmd eq 'subscribe') { $fanout->subscribe($channel); }
elsif ($cmd eq 'unsubscribe') { $fanout->unsubscribe($channel); }
elsif ($cmd eq 'announce') { $fanout->announce($channel, $msg); }
elsif ($cmd eq 'ping') { $fanout->send("ping\n"); }
elsif ($cmd eq 'info') { $fanout->send("info\n"); }
elsif ($cmd eq 'subscribe') { $fanout->subscribe($channel); }
elsif ($cmd eq 'unsubscribe') { $fanout->unsubscribe($channel); }
elsif ($cmd eq '') { } # NOP
elsif ($cmd eq 'help')
{
print <<EOX;
subscribe channel
unsubscribe channel
announce channel message
ping
info
EOX
}
else { print "unknown command '$cmd'\n"; }
}
}
......@@ -268,4 +285,3 @@ sub main
__END__
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment