SockJS-perl - a SockJS Perl Plack/PSGI implementation
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
SockJS client is required. You can get it from 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>
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(@_); } ); }; ); };
Read the install instructions in t-client/README. Start the test server and open a browser at http://localhost:8081 and run the qunit tests suite.
t-client/README
http://localhost:8081
Clone http://github.com/sockjs/sockjs-protocol and follow install instructions. Then start the test server setting TEST_PROTOCOL environment variable (this is needed for setting smaller response_limit) and then run the tests.
TEST_PROTOCOL
response_limit
# 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
Viacheslav Tykhanovskyi, "vti@cpan.org".
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.
To install SockJS, copy and paste the appropriate command in to your terminal.
cpanm
cpanm SockJS
CPAN shell
perl -MCPAN -e shell install SockJS
For more information on module installation, please visit the detailed CPAN module installation guide.