17. $env
Streaming Interface
sub {
my $responder = shift;
my $writer = $responder->([
'200',
[ 'Content-Type' => 'text/plain' ]);
# later, of in a callback
$writer->write(“Hello world!”);
$writer->close();
}
18. $env
Streaming Interface(Cont.)
sub {
my $responder = shift;
my $writer = $responder->([
'200',
[ 'Content-Type' => 'text/plain' ]);
# later, of in a callback
my $w; $w = AnyEvent->timer(after => 3,
cb => sub {
$writer->write(“Hello world!”);
$writer->close();
});
}
24. sub POE::Kernel::ASSERT_DEFAULT () { 1 }
use HTTP::Request;
use POE qw(Component::Client::HTTP);
POE::Component::Client::HTTP->spawn(
Alias => 'ua', # defaults to 'weeble'
Timeout => 20, # defaults to 180 seconds
);
POE::Session->create(
inline_states => {
_start => sub {
POE::Kernel->post(
'ua', # posts to the 'ua' alias
'request', # posts to ua's 'request' state
'response', # which of our states will receive the response
HTTP::Request->new(GET => “http://osdc.tw”),
);
},
_stop => sub {},
response => &response_handler,
},
);
POE::Kernel->run();
exit;
sub response_handler {
my ($request_packet, $response_packet) = @_[ARG0, ARG1];
my $request_object = $request_packet->[0];
my $response_object = $response_packet->[0];
}
44. Comet
The word comet came to English by way of the Latin word cometes. This word, in turn, came
from the Greek word κόμη, which means "hair of the head". The Greek scientist and
philosopher Aristotlefirst used the derived form of κόμη, κομήτης, to describe what he saw
as "stars with hair." Theastronomical symbol for comets is (☄), consisting of a small disc with
three hairlike extensions.
-
45. Comet
The word comet came to English by way of the Latin word cometes. This word, in turn, came
from the Greek word κόμη, which means "hair of the head". The Greek scientist and
philosopher Aristotlefirst used the derived form of κόμη, κομήτης, to describe what he saw
as "stars with hair." Theastronomical symbol for comets is (☄), consisting of a small disc with
three hairlike extensions.
-
• 2006
•
73. • : Websocket, MXHR
enable "+Web::Hippie";
sub { my $env = shift;
my $args = $env->{'hippie.args'};
my $handle = $env->{'hippie.handle'};
# Your handler based on PATH_INFO:
# /init, /error, /message
}
74. • : Websocket, MXHR
Just a normal PSGI-app!
enable "+Web::Hippie";
sub { my $env = shift;
my $args = $env->{'hippie.args'};
my $handle = $env->{'hippie.handle'};
# Your handler based on PATH_INFO:
# /init, /error, /message
}
75. • : Websocket, MXHR
mount it to /_hippie
enable "+Web::Hippie";
sub { my $env = shift;
my $args = $env->{'hippie.args'};
my $handle = $env->{'hippie.handle'};
# Your handler based on PATH_INFO:
# /init, /error, /message
}
83. Hippie::Pipe
• :
Websocket MXHR poll AnyMQ support
enable "+Web::Hippie";
enable "+Web::Hippie::Pipe", bus => AnyMQ->new;
sub { my $env = shift;
my $sub = $env->{'hippie.listener'};
my $bus = $env->{'hippie.bus'};
my $msg = $env->{'hippie.message'};
# Your handler based on PATH_INFO:
# /new_listener, /error, /message
}