Skip to content

Commit

Permalink
improved a few event descriptions
Browse files Browse the repository at this point in the history
  • Loading branch information
kraih committed Oct 31, 2011
1 parent 64f60be commit 0260ebd
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 15 deletions.
5 changes: 3 additions & 2 deletions lib/Mojo/Server/Daemon.pm
Expand Up @@ -402,7 +402,8 @@ Group for server process.
my $loop = $daemon->ioloop;
$daemon = $daemon->ioloop(Mojo::IOLoop->new);
Event loop for server I/O, defaults to the global L<Mojo::IOLoop> singleton.
Loop object to use for I/O operations, defaults to the global L<Mojo::IOLoop>
singleton.
=head2 C<keep_alive_timeout>
Expand Down Expand Up @@ -473,7 +474,7 @@ implements the following new ones.
$daemon->prepare_ioloop;
Prepare event loop.
Prepare loop.
=head2 C<run>
Expand Down
27 changes: 15 additions & 12 deletions lib/Mojolicious/Guides/Cookbook.pod
Expand Up @@ -292,8 +292,8 @@ block for too long.
</body>
</html>

See also L<Mojo::Transaction::WebSocket/"EVENTS"> for more information about
the events used in this example.
The C<finish> event will be emitted right after the WebSocket connection has
been closed.

=head2 Testing WebSockets

Expand Down Expand Up @@ -367,8 +367,8 @@ infrastructure requirements, since it reuses the HTTP protocol for transport.
</body>
</html>

See also L<Mojo::Transaction::HTTP/"EVENTS"> and L<Mojo::Log/"EVENTS"> for
more information about the events used in this example.
The C<message> event will be emitted for every new log message and the
C<finish> event right after the transaction has been finished.

=head1 USER AGENT

Expand Down Expand Up @@ -429,9 +429,9 @@ You can just add username and password to the URL.

=head2 Decorating followup requests

L<Mojo::UserAgent> can automatically follow redirects, the C<on_start>
callback allows you direct access to each transaction right after they have
been initialized and before a connection gets associated with them.
L<Mojo::UserAgent> can automatically follow redirects, the C<start> event
allows you direct access to each transaction right after they have been
initialized and before a connection gets associated with them.

# User agent following up to 10 redirects
my $ua = Mojo::UserAgent->new(max_redirects => 10);
Expand All @@ -450,15 +450,18 @@ This even works for proxy C<CONNECT> requests.

=head2 Streaming response

Receiving a streaming response can be really tricky in most HTTP clients,
Receiving a streaming response can be really tricky in most HTTP clients, but
L<Mojo::UserAgent> makes it actually easy.

my $ua = Mojo::UserAgent->new;
my $tx = $ua->build_tx(GET => 'http://mojolicio.us');
$tx->res->body(sub { say $_[1] });
$tx->res->content->on(read => sub {
my ($content, $chunk) = @_;
say $chunk;
});
$ua->start($tx);

The C<body> callback will be called for every chunk of data that is received,
The C<read> event will be emitted for every chunk of data that is received,
even C<chunked> encoding will be handled transparently if necessary.

=head2 Streaming request
Expand Down Expand Up @@ -567,10 +570,10 @@ time.
# Start a bunch of parallel crawlers sharing the same user agent
$crawl->($_) for 1 .. 3;

# Start event loop
# Start reactor
Mojo::IOLoop->start;

You can take full control of the L<Mojo::IOLoop> event loop.
You can take full control of the L<Mojo::IOLoop> reactor.

=head2 Parallel blocking requests

Expand Down
2 changes: 1 addition & 1 deletion lib/Mojolicious/Guides/Routing.pod
Expand Up @@ -756,7 +756,7 @@ Now just load the plugin and you're done.

You can restrict access to WebSocket handshakes using the C<websocket> method.

# /ws (WebSocket handshake)
# /echo (WebSocket handshake)
$r->websocket('/echo')->to(controller => 'foo', action => 'echo');

# Controller
Expand Down
3 changes: 3 additions & 0 deletions lib/Mojolicious/Lite.pm
Expand Up @@ -707,6 +707,9 @@ WebSocket applications have never been this easy before.
});
};
The C<message> event will be emitted for every new WebSocket message that is
received.
=head2 External templates
External templates will be searched by the renderer in a C<templates>
Expand Down

0 comments on commit 0260ebd

Please sign in to comment.