Денис Ибаев > MojoX-Transaction-WebSocket76 > MojoX::Transaction::WebSocket76

Download:
MojoX-Transaction-WebSocket76-0.04.tar.gz

Dependencies

Annotate this POD

View/Report Bugs
Module Version: 0.04   Source  

NAME ^

MojoX::Transaction::WebSocket76 - WebSocket version hixie-76 transaction container

SYNOPSIS ^

    use MojoX::Transaction::WebSocket76;

    my $ws = MojoX::Transaction::WebSocket76->new;

DESCRIPTION ^

MojoX::Transaction::WebSocket76 is a container for WebSocket transactions as described in hixie-76 draft. Support for this version of the protocol was removed in Mojolicious 1.17. But old version of the Safari browser (5.0.1) supports only it.

To support for both versions of the protocol (last and hixie-76 draft) in your Mojolicious application, add:

    # In application module.
    package MyApp;

    # Override Mojolicious::build_tx().
    sub build_tx {
        my ($self) = @_;
        # Use your own transaction module.
        my $tx = MyApp::Transaction->new;
        $self->plugins->emit_hook(after_build_tx => $tx, $self);
        return $tx;
    }

    # In transaction module.
    package MyApp::Transaction;

    use Mojo::Transaction::WebSocket;
    use MojoX::Transaction::WebSocket76;

    use Mojo::Base 'Mojo::Transaction::HTTP';

    # Override Mojo::Transaction::HTTP::server_read().
    sub server_read {
        # ...
        # Need to change only this piece of code.
        if (lc($req->headers->upgrade || '') eq 'websocket') {
            # Upgrade to WebSocket of needed version.
            $self->emit(upgrade =>
                  ($req->headers->header('Sec-WebSocket-Key1')
                && $req->headers->header('Sec-WebSocket-Key2'))
                    ? MojoX::Transaction::WebSocket76->new(handshake => $self)
                    : Mojo::Transaction::WebSocket->new(handshake => $self)
            );
        }
        # ...
    }

EVENTS ^

MojoX::Transaction::WebSocket76 inherits all events from Mojo::Transaction::WebSocket.

ATTRIBUTES ^

MojoX::Transaction::WebSocket76 inherits all attributes from Mojo::Transaction::WebSocket.

METHODS ^

MojoX::Transaction::WebSocket76 inherits all methods from Mojo::Transaction::WebSocket.

DEBUGGING ^

You can set the MOJO_WEBSOCKET_DEBUG environment variable to get some advanced diagnostics information printed to STDERR.

    MOJO_WEBSOCKET_DEBUG=1

SEE ALSO ^

Mojolicious, Mojo::Transaction::WebSocket.

SUPPORT ^

Repository

http://github.com/dionys/mojox-transaction-websocket76

Bug tracker

http://github.com/dionys/mojox-transaction-websocket76/issues

AUTHOR ^

Denis Ibaev, dionys@cpan.org for Setup.ru.

COPYRIGHT AND LICENSE ^

Copyright (C) 2012-2013, Denis Ibaev.

This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.

See http://dev.perl.org/licenses/ for more information.

syntax highlighting: