-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
vti
committed
Sep 13, 2011
1 parent
c1c7550
commit c0ce969
Showing
1 changed file
with
2 additions
and
117 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,123 +1,8 @@ | ||
|
||
=pod | ||
|
||
=head1 Plack::Middleware::SocketIO | ||
=head1 DEPRECATED | ||
|
||
L<Plack::Middleware::SocketIO> is a server implmentation of SocketIO in Perl. | ||
|
||
All the transports are supported. | ||
|
||
WebSocket | ||
Adobe® Flash® Socket | ||
AJAX long polling | ||
AJAX multipart streaming | ||
Forever Iframe | ||
JSONP Polling | ||
|
||
=head1 SocketIO | ||
|
||
More information about SocketIO you can find on the website L<http://socket.io/>, or | ||
on GitHub L<https://github.com/LearnBoost/Socket.IO>. | ||
|
||
=head1 EXAMPLE | ||
|
||
Below is an example similar to Socket.IO-node example chat. To run this example, | ||
you need to make the following simple steps: | ||
|
||
=over 4 | ||
|
||
=item 1. Clone somewhere L<https://github.com/LearnBoost/Socket.IO-node>. | ||
|
||
=item 2. Save the shown .psgi file, changing <$path_to_socket_io> so it points to the Socket.IO-node files. | ||
|
||
use Plack::Builder; | ||
use Plack::App::File; | ||
use Plack::Middleware::Static; | ||
use Plack::Middleware::SocketIO; | ||
|
||
my $path_to_socket_io = "/path/to/Socket.IO-node"; | ||
|
||
builder { | ||
mount '/socket.io/socket.io.js' => Plack::App::File->new( | ||
file => "$path_to_socket_io/support/socket.io-client/socket.io.js"); | ||
|
||
mount '/' => builder { | ||
enable "Static", | ||
path => qr/\.(?:js|css|jpe?g|gif|png|html?|js|css|swf|ico)$/, | ||
root => "$path_to_socket_io/example"; | ||
|
||
enable "SimpleLogger", level => 'debug'; | ||
|
||
enable "SocketIO", handler => sub { | ||
my $self = shift; | ||
|
||
$self->on_message( | ||
sub { | ||
my $self = shift; | ||
my ($message) = @_; | ||
|
||
$self->send_broadcast({message => [$self->id, $message]}); | ||
} | ||
); | ||
|
||
$self->on_disconnect( | ||
sub { | ||
$self->send_broadcast( | ||
{announcement => $self->id . ' disconnected'}); | ||
} | ||
); | ||
|
||
$self->send_message({buffer => []}); | ||
|
||
$self->send_broadcast({announcement => $self->id . ' connected'}); | ||
}; | ||
|
||
sub { | ||
[ 200, | ||
['Content-Type' => 'text/html'], | ||
['Open <a href="/chat.html">chat</a>.'] | ||
]; | ||
}; | ||
}; | ||
}; | ||
|
||
=item 3. Start L<Twiggy> or L<Fliggy> (same as L<Twiggy> but with inlined Flash Policy server) | ||
|
||
$ sudo flash-policy-server & | ||
$ twiggy chat.psgi --listen :8080 | ||
|
||
or | ||
|
||
$ fliggy chat.psgi --listen :8080 | ||
|
||
=item 4. Point your browser to | ||
|
||
http://localhost:8080 | ||
|
||
=back | ||
|
||
=head1 TLS/SSL | ||
|
||
For TLS/SSL a secure proxy is needed. C<stunnel> or L<App::TLSMe> is | ||
recommended. | ||
|
||
=head1 DISCLAIMER | ||
|
||
This middleware is in a very beta stage. API will be probably changed. | ||
|
||
=head1 CREDITS | ||
|
||
Socket.IO author(s) and contributors. | ||
|
||
=head1 AUTHOR | ||
|
||
Viacheslav Tykhanovskyi, C<vti@cpan.org>. | ||
|
||
=head1 COPYRIGHT | ||
|
||
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. | ||
Use L<http://github.com/vti/pocketio> instead. | ||
|
||
=cut |