=pod

=head1 NAME

SockJS-perl - a SockJS Perl Plack/PSGI implementation

=head1 DESCRIPTION

=head2 Supported features

Work's still in progress.

    WebSocket (hixie-75, hixie-76/hybi-00, hybi-10, hybi-17 and various tweaks)
    XHR Polling/Streaming
    JSONP Polling
    EventSource
    HtmlFile
    IFrame XHR Polling/EvenSource/HtmlFile

    JSessionID

=head2 The Client-Side Part

SockJS client is required. You can get it from
L<http://sockjs.github.com/sockjs-client>.

    <script src="http://cdn.sockjs.org/sockjs-0.2.1.min.js"></script>

    <script>
      var sock = new SockJS("http://mydomain.com/my_prefix");

      sock.onopen = function() {
        console.log("open");
      };

      sock.onmessage = function(e) {
        console.log("message", e.data);
      };

      sock.onclose = function() {
        console.log("close");
      };
    </script>

=head2 The Server-Side Part

Here is a simple echo server.

    #!/usr/bin/env perl

    use strict;
    use warnings;

    use Plack::Builder;
    use SockJS;

    builder {
        mount '/echo' => SockJS->new(
            handler => sub {
                my ($session) = @_;

                $session->on(
                    'data' => sub {
                        my $session = shift;

                        $session->write(@_);
                    }
                );
            };
        );
    };

=head2 Running browser tests

Read the install instructions in C<t-client/README>. Start the test server and
open a browser at C<http://localhost:8081> and run the qunit tests suite.

=head2 Running protocol tests

Clone L<http://github.com/sockjs/sockjs-protocol> and follow install
instructions. Then start the test server setting C<TEST_PROTOCOL> environment
variable (this is needed for setting smaller C<response_limit>) and then run the
tests.

    # Run all the tests.
    ./venv/bin/python sockjs-protocol-dev.py

    # Run all the tests defined in XhrStreaming.
    ./venv/bin/python sockjs-protocol-dev.py XhrStreaming

    # Run only XhrStreaming.test_transport test.
    ./venv/bin/python sockjs-protocol-dev.py XhrStreaming.test_transport

=head1 AUTHOR

Viacheslav Tykhanovskyi, "vti@cpan.org".

=head1 COPYRIGHT AND LICENSE

Copyright (C) 2012, 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.
