butting with fortunes!
This commit is contained in:
parent
24ecdb163d
commit
f11a159bce
|
@ -0,0 +1,38 @@
|
|||
#!/usr/bin/env perl
|
||||
|
||||
use strict;
|
||||
use warnings;
|
||||
|
||||
use POE;
|
||||
use POE::Component::Server::TCP;
|
||||
|
||||
use Butts;
|
||||
# search $PATH by default.
|
||||
my $fortune = 'fortune';
|
||||
|
||||
# Start a TCP server. Client input will be logged to the console and
|
||||
# echoed back to the client, one line at a time.
|
||||
my $butter = Butts->new();
|
||||
|
||||
POE::Component::Server::TCP->new
|
||||
(
|
||||
Alias => "echo_server",
|
||||
Port => $ARGV[0] // 1096,
|
||||
ClientInput => sub {
|
||||
$_[KERNEL]->yield('shutdown');
|
||||
},
|
||||
ClientConnected => sub {
|
||||
my ($kernel, $session, $heap, $input) = @_[KERNEL, SESSION, HEAP, ARG0];
|
||||
#print "Session ", $session->ID(), " got input: $input\n";
|
||||
|
||||
my @fortune = `$fortune`; # ick. But Fortune.pm is shit.
|
||||
foreach my $line (@fortune) {
|
||||
$heap->{client}->put($butter->buttify_string($line));
|
||||
}
|
||||
$kernel->yield("shutdown");
|
||||
}
|
||||
);
|
||||
|
||||
# Start the server.
|
||||
$poe_kernel->run();
|
||||
exit 0;
|
Loading…
Reference in New Issue