Guest User

Untitled

a guest
Jan 14th, 2018
68
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.22 KB | None | 0 0
  1. #!/usr/bin/perl
  2.  
  3. use warnings;
  4. use strict;
  5.  
  6. use lib '../lib';
  7.  
  8. use Data::Dumper;
  9.  
  10. use POE qw(SAPI);
  11. use POE::SAPI::HandySubs qw(pad);
  12.  
  13. POE::Session->create(
  14. inline_states => {
  15. _start => \&init,
  16. comm => \&comm,
  17. },
  18. );
  19.  
  20. POE::Kernel->run();
  21. exit;
  22.  
  23. sub init {
  24. my ($kernel,$session,$heap) = @_[KERNEL,SESSION,HEAP];
  25. $heap->{SAPI} = POE::SAPI->new({ }); # Note no options yet
  26. }
  27. sub comm {
  28. my ($kernel,$session,$heap,$req) = @_[KERNEL,SESSION,HEAP,ARG0];
  29.  
  30. $req->{src} = "UNKNOWN" if (!$req->{src});
  31.  
  32. if (!$req->{type}) { $kernel->yield('comm',{ type=>"debug", level=>"critical", msg=>"Just passed a request with no type!", original=
  33. else {
  34. print "[" . pad($req->{src},12," ") . "], $req->{type}: $req->{msg}\n";
  35. }
  36.  
  37. return if (!$req->{code});
  38.  
  39. if ($req->{code} eq 'N_COREREADY') {
  40. $kernel->yield('comm',{ type=>"debug", level=>"debug", msg=>"Core Ready - Initilizing config" } );
  41. $kernel->post('SAPI','config',{ type=>"init" });
  42. }
  43.  
  44. # $kernel->post("LocalAuth","auth",{username=>'Auser',password=>'MyPassword'});
  45. }
Add Comment
Please, Sign In to add comment