#!/usr/bin/perl -w
use strict;
sub DEBUG () {0}
use POE::Component::IKC::ClientLite;
my $port = shift || 1337;
my $name = shift || 'LiteClient';
my $norecon = shift || 0;
DEBUG and warn "$$: Connect\n";
my $poe=POE::Component::IKC::ClientLite->spawn(
port=>$port,
name=>$name,
protocol=>'IKC0'
);
die $POE::Component::IKC::ClientLite::error unless $poe;
DEBUG and warn "$$: call\n";
my $n=$poe->call('test/fetchQ') or die $poe->error;
DEBUG and warn "$$: post_respond\n";
$n=$poe->post_respond('test/add_1'=>$n) or die $poe->error;
unless( $norecon ) {
DEBUG and warn "$$: disconnect\n";
$poe->{remote}{socket}->close; # test autoreconnect
$poe->{protocol} = 'IKC'; # test fallback
}
else {
sleep 1;
}
DEBUG and warn "$$: post\n";
$poe->post('test/here'=>$n) or die $poe->error;
DEBUG and warn "$$: disconnect\n";
$poe->disconnect; # for real
DEBUG and warn "$$: Client exiting\n";