Advertisement
Guest User

Untitled

a guest
Mar 28th, 2014
63
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Perl 1.11 KB | None | 0 0
  1. #!/usr/bin/env perl
  2. use Mojolicious::Lite;
  3.  
  4. use lib 'lib';
  5. use Hostinfo;
  6. use Conty;
  7.  
  8. get '/' => 'index';
  9.  
  10. helper 'hostinfo' => sub { Hostinfo->new() };
  11. helper 'conty' => sub { Conty->new() };
  12.  
  13. websocket '/stylehouse' => sub {
  14.     my $self = shift;
  15.  
  16.     $self->app->log->info("WebSocket opened");
  17.  
  18.     $self->on(message => sub {
  19.         my ($self, $msg) = @_;
  20.  
  21.         $self->app->log->info("WebSocket: $msg");
  22.         Mojo::IOLoop->stream($self->tx->connection)->timeout(300000);
  23.  
  24.         $self->conty->message($self, $msg);
  25.     });
  26.  
  27.     $self->app->log->info("happens:!". anydump($self->app->conty));
  28.     $self->conty->initiate();
  29. };
  30.  
  31. package Conty;
  32. use Mojo::Base 'Mojolicious::Controller';
  33. use Scriptalicious;
  34. use Texty;
  35.  
  36. my @apps;
  37.  
  38. sub initiate { # notice a screen
  39.     my $self = shift;
  40.     $self->app->log->info("Doesn't work". anydump($self->app->conty));
  41.     # Can't locate object method "conty" via package "Mojolicious" at lib/Conty.pm line 10.
  42.     # or $self->hostinfo
  43.  
  44.     $self->app->send("ws.send('screen: '+screen.availWidth+'x'+screen.availHeight.')");
  45.     # startup things...
  46. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement