#!/usr/bin/perl
use warnings;
use strict;

use POE;
use POE::Component::Client::TCP;

POE::Component::Client::TCP->new(
    RemoteAddress => 'localhost',
    RemotePort => 22224,
    Connected => sub {
        print "Jsme připojeni\n";
    },
    ServerInput => sub {
        my $odpoved = $_[ARG0];
        print "Výsledek: $odpoved\n";
        $_[KERNEL]->yield("proved");
    },
    InlineStates => {
        proved => sub {
            print "příkaz> ";
            my $cmd = <STDIN>;
            if($cmd =~ m/\A(?:quit|q|exit|konec)/){
                $_[KERNEL]->yield("shutdown");
                return;
            }
            $_[HEAP]{server}->put($cmd);
        }
    }
);

POE::Kernel->run();
