From 52385368489377f124ec66621dbd6c5852ffe8ec Mon Sep 17 00:00:00 2001 From: Gerhard Gonter <ggonter@gmail.com> Date: Wed, 24 May 2023 21:13:30 +0200 Subject: [PATCH] standalone mode: added help and POD section --- modules/util/Net/fanout.pm | 24 ++++++++++++++++++++---- 1 file changed, 20 insertions(+), 4 deletions(-) diff --git a/modules/util/Net/fanout.pm b/modules/util/Net/fanout.pm index 57d0e4b..1188ccc 100644 --- a/modules/util/Net/fanout.pm +++ b/modules/util/Net/fanout.pm @@ -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__ - -- GitLab