NAME
SockJS-perl - a SockJS Perl Plack/PSGI implementation
DESCRIPTION
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
The Client-Side Part
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>
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(@_);
}
);
};
);
};
Running browser tests
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.
Running protocol tests
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.
# 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
AUTHOR
Viacheslav Tykhanovskyi, "vti@cpan.org".
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.