Skip to content

Commit

Permalink
Moved to PocketIO. Closes #GH-5
Browse files Browse the repository at this point in the history
  • Loading branch information
vti committed Nov 15, 2011
1 parent 201e2a6 commit 5c56e0c
Show file tree
Hide file tree
Showing 12 changed files with 49 additions and 19 deletions.
8 changes: 8 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
*.sw[p-z]
blib
Makefile
MANIFEST
Makefile.old
pm_to_blib
*.bak
*~
3 changes: 0 additions & 3 deletions .gitmodules

This file was deleted.

2 changes: 1 addition & 1 deletion INSTALL
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ Showmetheshell installation steps:
installing them as a local user read more about App::cpanminus)

bin/cpanm --sudo IO::Pty Term::VT102 JSON Plack Twiggy \
Plack::Middleware::SocketIO Text::Caml
PocketIO Text::Caml

* Start the server

Expand Down
1 change: 0 additions & 1 deletion contrib/socket.io
Submodule socket.io deleted from ec0237
Binary file added htdocs/WebSocketMain.swf
Binary file not shown.
Binary file added htdocs/WebSocketMainInsecure.swf
Binary file not shown.
2 changes: 2 additions & 0 deletions htdocs/socket.io.min.js

Large diffs are not rendered by default.

1 change: 0 additions & 1 deletion htdocs/socket.io/WebSocketMain.swf

This file was deleted.

1 change: 0 additions & 1 deletion htdocs/socket.io/socket.io.js

This file was deleted.

14 changes: 7 additions & 7 deletions lib/Handler.pm
Original file line number Diff line number Diff line change
Expand Up @@ -35,24 +35,24 @@ sub run {

my $message = JSON->new->encode(
{type => 'row', row => $row, text => $text});
$self->send_message($message);
$self->send($message);
},
on_cursor_move => sub {
my ($terminal, $x, $y) = @_;

my $message =
JSON->new->encode({type => 'cursor', x => $x, y => $y});
$self->send_message($message);
$self->send($message);
},
on_finished => sub {
my $terminal = shift;

$self->disconnect;
$self->close;
}
);

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

my $json = JSON->new;
Expand All @@ -77,8 +77,8 @@ sub run {
}
);

$self->on_disconnect(
sub {
$self->on(
disconnect => sub {
}
);

Expand Down
32 changes: 29 additions & 3 deletions showmetheshell.psgi
Original file line number Diff line number Diff line change
@@ -1,12 +1,26 @@
use strict;
use warnings;

my $root;

BEGIN {
use File::Basename ();
use File::Spec ();

$root = File::Basename::dirname(__FILE__);
$root = File::Spec->rel2abs($root);

unshift @INC, "$root/../../lib";
}

use lib 'lib';

use Plack::Builder;
use Plack::App::File;

use Handler;
use Text::Caml;
use PocketIO;

my $caml = Text::Caml->new(templates_path => 'templates');

Expand All @@ -22,12 +36,24 @@ my $app = sub {
};

builder {
mount '/socket.io/static/flashsocket/WebSocketMain.swf' =>
Plack::App::File->new(file => "$root/htdocs/WebSocketMain.swf");

mount '/socket.io/static/flashsocket/WebSocketMainInsecure.swf' =>
Plack::App::File->new(file => "$root/htdocs/WebSocketMainInsecure.swf");

enable "Static",
path => qr/\.(?:js|css|jpe?g|gif|png|html?|swf|ico)$/,
root => 'htdocs';

enable "SocketIO",
instance => Handler->new(cmd => '/bin/bash');
mount '/socket.io' =>
PocketIO->new(instance => Handler->new(cmd => '/bin/bash'));

mount '/' => builder {
enable "Static",
path => qr/\.(?:js|css|jpe?g|gif|png|html?|swf|ico)$/,
root => "$root/public";

$app;
$app;
};
};
4 changes: 2 additions & 2 deletions templates/index.caml
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@
<script type="text/javascript" src="/jquery.json.js"></script>
<script type="text/javascript" src="/shell.js"></script>
<script>WEB_SOCKET_SWF_LOCATION = '/socket.io/WebSocketMain.swf';</script>
<script type="text/javascript" src="/socket.io/socket.io.js"></script>
<script type="text/javascript" src="/socket.io.min.js"></script>
<script type="text/javascript">
$(document).ready(function() {
var socket = new io.Socket(null, {port: 5000, rememberTransport: false});
var socket = io.connect();
var shell = new Shell();

socket.on('message', function(data) {
Expand Down

0 comments on commit 5c56e0c

Please sign in to comment.