line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package JLogger::Transport; |
2
|
|
|
|
|
|
|
|
3
|
1
|
|
|
1
|
|
783
|
use strict; |
|
1
|
|
|
|
|
4
|
|
|
1
|
|
|
|
|
41
|
|
4
|
1
|
|
|
1
|
|
10
|
use warnings; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
485
|
|
5
|
|
|
|
|
|
|
|
6
|
|
|
|
|
|
|
require Carp; |
7
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
sub new { |
9
|
1
|
|
|
1
|
0
|
684
|
my ($class, %args) = @_; |
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
Carp::croak('Required "host" argument missing!') |
12
|
1
|
50
|
|
|
|
5
|
unless exists $args{host}; |
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
Carp::croak('Required "port" argument missing!') |
15
|
1
|
50
|
|
|
|
4
|
unless exists $args{port}; |
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
Carp::croak('Required "secret" argument missing!') |
18
|
1
|
50
|
|
|
|
3
|
unless exists $args{secret}; |
19
|
|
|
|
|
|
|
|
20
|
1
|
|
50
|
0
|
|
10
|
$args{on_disconnect} ||= sub {}; |
21
|
|
|
|
|
|
|
|
22
|
1
|
|
|
|
|
6
|
my $self = bless {%args}, $class; |
23
|
|
|
|
|
|
|
|
24
|
1
|
|
|
|
|
6
|
$self->init; |
25
|
|
|
|
|
|
|
|
26
|
1
|
|
|
|
|
4
|
$self; |
27
|
|
|
|
|
|
|
} |
28
|
|
|
|
|
|
|
|
29
|
0
|
|
|
0
|
0
|
|
sub domain { $_[0]->{domain} } |
30
|
|
|
|
|
|
|
|
31
|
0
|
|
|
0
|
1
|
|
sub host { $_[0]->{host} } |
32
|
|
|
|
|
|
|
|
33
|
0
|
|
|
0
|
1
|
|
sub port { $_[0]->{port} } |
34
|
|
|
|
|
|
|
|
35
|
0
|
|
|
0
|
1
|
|
sub secret { $_[0]->{secret} } |
36
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
sub on_message { |
38
|
0
|
0
|
|
0
|
1
|
|
@_ > 1 ? $_[0]->{on_message} = $_[1] : $_[0]->{on_message}; |
39
|
|
|
|
|
|
|
} |
40
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
sub on_disconnect { |
42
|
0
|
0
|
|
0
|
0
|
|
@_ > 1 ? $_[0]->{on_disconnect} = $_[1] : $_[0]->{on_disconnect}; |
43
|
|
|
|
|
|
|
} |
44
|
|
|
|
|
|
|
|
45
|
|
|
|
1
|
1
|
|
sub init { |
46
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
} |
48
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
sub connect { |
50
|
0
|
|
|
0
|
1
|
|
my $self = shift; |
51
|
|
|
|
|
|
|
|
52
|
0
|
|
|
|
|
|
Carp::croak(qq(You didn't implemented "connect" in @{[ ref $self ]})); |
|
0
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
} |
54
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
sub disconnect { |
56
|
0
|
|
|
0
|
0
|
|
my $self = shift; |
57
|
|
|
|
|
|
|
|
58
|
0
|
|
|
|
|
|
Carp::croak(qq(You didn't implemented "disconnect" in @{[ ref $self ]})); |
|
0
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
} |
60
|
|
|
|
|
|
|
|
61
|
|
|
|
|
|
|
1; |
62
|
|
|
|
|
|
|
__END__ |