| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
package POEIKC::Daemon::P2P; |
|
2
|
|
|
|
|
|
|
|
|
3
|
1
|
|
|
1
|
|
6
|
use strict; |
|
|
1
|
|
|
|
|
1
|
|
|
|
1
|
|
|
|
|
42
|
|
|
4
|
1
|
|
|
1
|
|
32
|
use 5.008_001; |
|
|
1
|
|
|
|
|
4
|
|
|
|
1
|
|
|
|
|
40
|
|
|
5
|
|
|
|
|
|
|
|
|
6
|
1
|
|
|
1
|
|
6
|
use warnings; |
|
|
1
|
|
|
|
|
2
|
|
|
|
1
|
|
|
|
|
33
|
|
|
7
|
1
|
|
|
1
|
|
5
|
use Data::Dumper; |
|
|
1
|
|
|
|
|
2
|
|
|
|
1
|
|
|
|
|
217
|
|
|
8
|
1
|
|
|
1
|
|
6
|
use UNIVERSAL::require; |
|
|
1
|
|
|
|
|
2
|
|
|
|
1
|
|
|
|
|
11
|
|
|
9
|
1
|
|
|
|
|
8
|
use POE qw( |
|
10
|
|
|
|
|
|
|
Sugar::Args |
|
11
|
|
|
|
|
|
|
Loop::IO_Poll |
|
12
|
|
|
|
|
|
|
Component::IKC::Client |
|
13
|
1
|
|
|
1
|
|
42
|
); |
|
|
1
|
|
|
|
|
10
|
|
|
14
|
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
use POEIKC; |
|
16
|
|
|
|
|
|
|
our $VERSION = $POEIKC::VERSION; |
|
17
|
|
|
|
|
|
|
use POEIKC::Daemon; |
|
18
|
|
|
|
|
|
|
use POEIKC::Daemon::Utility; |
|
19
|
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
#### |
|
21
|
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
sub connect { |
|
24
|
|
|
|
|
|
|
my $poe = sweet_args ; |
|
25
|
|
|
|
|
|
|
my $kernel = $poe->kernel ; |
|
26
|
|
|
|
|
|
|
my $object = $poe->object; |
|
27
|
|
|
|
|
|
|
my $session = $poe->session; |
|
28
|
|
|
|
|
|
|
my ( $server, $hash , $delay) = @{$poe->args} ; |
|
29
|
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
return $POEIKC::Daemon::connected{$server} |
|
31
|
|
|
|
|
|
|
if $server and $POEIKC::Daemon::connected{$server}; |
|
32
|
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
$POEIKC::Daemon::DEBUG and POEIKC::Daemon::Utility::_DEBUG_log($server, $delay, $hash); |
|
34
|
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
my $ret = $object->create_client( $hash, $server ); |
|
36
|
|
|
|
|
|
|
$delay and $kernel->delay(connect => $delay, $server, $hash, $delay); |
|
37
|
|
|
|
|
|
|
return $ret; |
|
38
|
|
|
|
|
|
|
} |
|
39
|
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
sub connected { |
|
42
|
|
|
|
|
|
|
my $self = shift; |
|
43
|
|
|
|
|
|
|
my $server = shift; |
|
44
|
|
|
|
|
|
|
return $POEIKC::Daemon::connected{$server}; |
|
45
|
|
|
|
|
|
|
} |
|
46
|
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
sub create_client { |
|
49
|
|
|
|
|
|
|
my $self = shift; |
|
50
|
|
|
|
|
|
|
my $hash = shift; |
|
51
|
|
|
|
|
|
|
my $server = shift; |
|
52
|
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
return $POEIKC::Daemon::connected{$server} |
|
54
|
|
|
|
|
|
|
if $server and $POEIKC::Daemon::connected{$server}; |
|
55
|
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
if ( $hash->{aliases} ) { |
|
57
|
|
|
|
|
|
|
if (ref $hash->{aliases} eq 'ARRAY'){ |
|
58
|
|
|
|
|
|
|
my $flag; |
|
59
|
|
|
|
|
|
|
for ( @{$hash->{aliases}} ) { |
|
60
|
|
|
|
|
|
|
$flag = 1 if $POEIKC::Daemon::opt{name} eq $_; |
|
61
|
|
|
|
|
|
|
} |
|
62
|
|
|
|
|
|
|
push @{$hash->{aliases}}, $POEIKC::Daemon::opt{name} if not $flag; |
|
63
|
|
|
|
|
|
|
}else{ |
|
64
|
|
|
|
|
|
|
my $aliases = $hash->{aliases}; |
|
65
|
|
|
|
|
|
|
$hash->{aliases} = []; |
|
66
|
|
|
|
|
|
|
push @{$hash->{aliases}}, ($aliases, $POEIKC::Daemon::opt{name}); |
|
67
|
|
|
|
|
|
|
} |
|
68
|
|
|
|
|
|
|
}else{ |
|
69
|
|
|
|
|
|
|
push @{$hash->{aliases}}, ($POEIKC::Daemon::opt{name}); |
|
70
|
|
|
|
|
|
|
} |
|
71
|
|
|
|
|
|
|
|
|
72
|
|
|
|
|
|
|
$hash->{name} ||= $POEIKC::Daemon::opt{name} . join('_'=>__PACKAGE__ =~ m/(\w+)/g); |
|
73
|
|
|
|
|
|
|
|
|
74
|
|
|
|
|
|
|
$POEIKC::Daemon::DEBUG and POEIKC::Daemon::Utility::_DEBUG_log($hash); |
|
75
|
|
|
|
|
|
|
|
|
76
|
|
|
|
|
|
|
POE::Component::IKC::Client->spawn(%{$hash}); |
|
77
|
|
|
|
|
|
|
} |
|
78
|
|
|
|
|
|
|
|
|
79
|
|
|
|
|
|
|
|
|
80
|
|
|
|
|
|
|
1; |
|
81
|
|
|
|
|
|
|
__END__ |