Skip to content

Commit

Permalink
mention subprotocol negotiation too
Browse files Browse the repository at this point in the history
  • Loading branch information
kraih committed Dec 15, 2015
1 parent 7c5aa51 commit e4e8165
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 0 deletions.
1 change: 1 addition & 0 deletions lib/Mojo/UserAgent.pm
Expand Up @@ -859,6 +859,7 @@ object, depending on if the handshake was successful.
$ua->websocket('wss://example.com/echo' => ['v1.proto'] => sub {
my ($ua, $tx) = @_;
say 'WebSocket handshake failed!' and return unless $tx->is_websocket;
say 'Subprotocol negotiation failed!' and return unless $tx->protocol;
$tx->on(finish => sub {
my ($tx, $code, $reason) = @_;
say "WebSocket closed with status $code.";
Expand Down
5 changes: 5 additions & 0 deletions lib/Mojolicious/Guides/Cookbook.pod
Expand Up @@ -637,6 +637,11 @@ L<Mojo::Transaction::WebSocket/"with_compression">, this can result in much
better performance, but also increases memory usage by up to 300KB per
connection.

my $proto = $c->tx->with_protocols('v2.proto', 'v1.proto');

Or negotiate a subprotocol with
L<Mojo::Transaction::WebSocket/"with_protocols">.

=head2 Testing WebSocket web services

While the message flow on WebSocket connections can be rather dynamic, it more
Expand Down

0 comments on commit e4e8165

Please sign in to comment.