#!/usr/bin/perl -w
use strict;
use CipUX::RPC::Client;
use English qw( -no_match_vars);

# prep
my $rpc = CipUX::RPC::Client->new(
    {
        url     => 'http://localhost:8001/RPC2',
        client  => 'cipux_rpc_login_session_logout',
        version => '0.0.1',
    }
);
my $s = {};

# start calling
eval { $rpc->rpc_ping; };
die "Server is down! $EVAL_ERROR" if $EVAL_ERROR;
my $ok = $rpc->rpc_login;
if ($ok) {
    my $t1 = $rpc->get_ticket;
    print "\tfirst session  [$t1]\n";
    my $t2 = $rpc->rpc_session;
    if($t2){
        print "\tsecond session [$t2]\n";
        $rpc->rpc_logout;
    }else{
        print "\tno second session\n";
    }
}
else {
    print 'No access for ' . $rpc->get_login . "!\n";
    print "Wrong password?\n";
}
