Вячеслав Тихановский > Plack-Middleware-SocketIO > Plack::Middleware::SocketIO

Download:
Plack-Middleware-SocketIO-0.00904.tar.gz

Dependencies

Annotate this POD

View/Report Bugs
Module Version: 0.00904   Source  

NAME ^

Plack::Middleware::SocketIO - Socket.IO middleware DEPRECATED

SYNOPSIS ^

    use Plack::Builder;

    builder {
        enable "SocketIO", handler => sub {
            my $self = shift;

            $self->on_message(
                sub {
                    my $self = shift;
                    my ($message) = @_;

                    ...
                }
            );

            $self->send_message({buffer => []});
        };

        $app;
    };

    # or

    builder {
        enable "SocketIO", class => 'MyApp::Handler', method => 'run';

        $app;
    };

DESCRIPTION ^

DEPRECATED. Use PocketIO instead http://github.com/vti/pocketio.

Plack::Middleware::SocketIO is a server implmentation of SocketIO in Perl.

SocketIO

More information about SocketIO you can find on the website http://socket.io/, or on the GitHub https://github.com/LearnBoost/Socket.IO.

Transports

All the transports are supported.

    WebSocket
    Adobe(R) Flash(R) Socket
    AJAX long polling
    AJAX multipart streaming
    Forever Iframe
    JSONP Polling

TLS/SSL

For TLS/SSL a secure proxy is needed. stunnel or App::TLSMe is recommended.

CONFIGURATIONS ^

resource
    enable "SocketIO",
        resource => 'socket.io', ...;

Specifies the path prefix under which all the requests are handled. This is done so the rest of your application won't interfere with Socket.IO specific calls.

handler
    enable "SocketIO",
        handler => sub {
            my $socket = shift;

            $socket->on_message(sub {
                my $socket = shift;
            });

            $socket->send_message('hello');
        };
class or instance, method
    enable "SocketIO",
        class => 'MyHandler', method => 'run';

    # or

    enable "SocketIO",
        instance => MyHandler->new(foo => 'bar'), method => 'run';

    package MyHandler;

    sub new { ...  } # or use Moose, Boose, Goose, Doose

    sub run {
        my $self = shift;

        return sub {

            # same code as above
        }
    }

Loads class using Plack::Util::load_class, creates a new object or uses a passed instance and runs run method expecting it to return an anonymous subroutine.

DEVELOPMENT ^

Repository

    http://github.com/vti/plack-middleware-socketio

CREDITS ^

Socket.IO author(s) and contributors.

AUTHOR ^

Viacheslav Tykhanovskyi, vti@cpan.org.

COPYRIGHT AND LICENSE ^

Copyright (C) 2011, Viacheslav Tykhanovskyi

This program is free software, you can redistribute it and/or modify it under the terms of the Artistic License version 2.0.

syntax highlighting: