| 1 | package POE::Component::Omegle; | ||
| 2 | |||
| 3 | 1 | ▶ | use 5.006000; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 4 | 1 | ▶ | use strict; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 5 | 1 | ▶ | use warnings; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 6 | |||
| 7 | 1 | ▶ | use POE; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 8 | |||
| 9 | 1 | our $VERSION = '0.02'; | |
| 10 | |||
| 11 | 0 | ▶ | sub new { |
|
Subroutine
new: not called CC=1 SCAR=6.9
Pod
undocumented
| |||
| 12 | 0 | my $class = shift; | |
| 13 | 0 | my @args = @_; | |
| 14 | |||
| 15 | 0 | my $self = { | |
| 16 | session => POE::Session->create( | ||
| 17 | package_states => [ | ||
| 18 | OMSession => [qw/_start _stop start_chat say disconnect set_callback | ||
| 19 | on_event_handled poke/], | ||
| 20 | ], | ||
| 21 | args => \@args, | ||
| 22 | ), | ||
| 23 | }; | ||
| 24 | |||
| 25 | 0 | bless $self, $class; | |
| 26 | 0 | return $self; | |
| 27 | } | ||
| 28 | |||
| 29 | 0 | ▶ | sub AUTOLOAD { |
|
Subroutine
AUTOLOAD: not called CC=1 SCAR=1.7
| |||
| 30 | 0 | my $self = shift; | |
| 31 | |||
| 32 | 1 | ▶ | use vars qw($AUTOLOAD); |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 33 | 0 | my $state = $AUTOLOAD; | |
| 34 | 0 | $state =~ s/.*:://; | |
| 35 | 0 | $poe_kernel->post( $self->{session} => $state => @_ ); | |
| 36 | } | ||
| 37 | |||
| 38 | |||
| 39 | ##### | ||
| 40 | |||
| 41 | package OMSession; | ||
| 42 | |||
| 43 | 1 | ▶ | use strict; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 44 | 1 | ▶ | use warnings; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 45 | |||
| 46 | 1 | ▶ | use POE; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 47 | 1 | ▶ | use WWW::Omegle; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 48 | |||
| 49 | |||
| 50 | 0 | ▶ | sub _start { |
|
Subroutine
_start: not called CC=1 SCAR=6.9
| |||
| 51 | 0 | my ($kernel, $sender, $heap, $session, %args) = @_[KERNEL, SENDER, HEAP, SESSION, ARG0..$#_]; | |
| 52 | |||
| 53 | 0 | my $om = $heap->{om} = new WWW::Omegle(); | |
| 54 | 0 | $kernel->yield(set_callback => 'event_handled', $session->postback('on_event_handled')); | |
| 55 | } | ||
| 56 | |||
| 57 | 0 | ▶ | sub set_callback { |
|
Subroutine
set_callback: not called CC=1 SCAR=6.9
| |||
| 58 | 0 | my ($sender, $heap, $callback, $state, @extra) = @_[SENDER, HEAP, ARG0, ARG1, ARG2..$#_]; | |
| 59 | 0 | $heap->{om}->set_callback($callback => $sender->postback($state), @extra); | |
| 60 | } | ||
| 61 | |||
| 62 | 0 | ▶ | sub _stop {} |
|
Subroutine
_stop: not called CC=1 SCAR=0.0
| |||
| 63 | |||
| 64 | # initiate a convo | ||
| 65 | 0 | ▶ | sub start_chat { |
|
Subroutine
start_chat: not called CC=1 SCAR=6.9
| |||
| 66 | 0 | my ($kernel, $sender, $heap, $pb) = @_[KERNEL, SENDER, HEAP, ARG0]; | |
| 67 | |||
| 68 | 0 | $heap->{om}->start; | |
| 69 | } | ||
| 70 | |||
| 71 | 0 | ▶ | sub poke { |
|
Subroutine
poke: not called CC=1 SCAR=6.9
| |||
| 72 | 0 | my ($kernel, $sender, $heap) = @_[KERNEL, SENDER, HEAP]; | |
| 73 | 0 | $heap->{om}->poke; | |
| 74 | } | ||
| 75 | |||
| 76 | 0 | ▶ | sub on_event_handled { |
|
Subroutine
on_event_handled: not called CC=1 SCAR=6.9
| |||
| 77 | 0 | my ($sender, $heap, $success) = @_[SENDER, HEAP, ARG0]; | |
| 78 | } | ||
| 79 | |||
| 80 | 0 | ▶ | sub say { |
|
Subroutine
say: not called CC=1 SCAR=6.9
| |||
| 81 | 0 | my ($sender, $heap, $msg) = @_[SENDER, HEAP, ARG0]; | |
| 82 | 0 | $heap->{om}->say($msg); | |
| 83 | } | ||
| 84 | |||
| 85 | 0 | ▶ | sub disconnect { |
|
Subroutine
disconnect: not called CC=1 SCAR=6.9
| |||
| 86 | 0 | my ($sender, $heap) = @_[SENDER, HEAP]; | |
| 87 | 0 | $heap->{om}->disconnect; | |
| 88 | } | ||
| 89 | |||
| 90 | 1 | 1; | |
| 91 | __END__ | ||