ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/AnyEvent-FCP/FCP.pm
(Generate patch)

Comparing AnyEvent-FCP/FCP.pm (file contents):
Revision 1.17 by root, Sat Sep 5 19:36:12 2015 UTC vs.
Revision 1.18 by root, Thu Dec 3 19:07:57 2015 UTC

61 61
62use common::sense; 62use common::sense;
63 63
64use Carp; 64use Carp;
65 65
66our $VERSION = '0.3'; 66our $VERSION = 0.4;
67 67
68use Scalar::Util (); 68use Scalar::Util ();
69 69
70use AnyEvent; 70use AnyEvent;
71use AnyEvent::Handle; 71use AnyEvent::Handle;
105 105
106 my $self = bless { 106 my $self = bless {
107 host => $ENV{FREDHOST} || "127.0.0.1", 107 host => $ENV{FREDHOST} || "127.0.0.1",
108 port => $ENV{FREDPORT} || 9481, 108 port => $ENV{FREDPORT} || 9481,
109 timeout => 3600 * 2, 109 timeout => 3600 * 2,
110 keepalive => 9 * 60,
110 name => time.rand.rand.rand, # lame 111 name => time.rand.rand.rand, # lame
111 @_, 112 @_,
112 queue => [], 113 queue => [],
113 req => {}, 114 req => {},
114 prefix => "..:aefcpid:$rand:", 115 prefix => "..:aefcpid:$rand:",
115 idseq => "a0", 116 idseq => "a0",
116 }, $class; 117 }, $class;
117 118
118 { 119 {
119 Scalar::Util::weaken (my $self = $self); 120 Scalar::Util::weaken (my $self = $self);
121
122 $self->{kw} = AE::timer $self->{keepalive}, $self->{keepalive}, sub {
123 $self->{hdl}->push_write ("\n");
124 };
120 125
121 our $ENDMESSAGE = qr<\012(EndMessage|Data)\012>; 126 our $ENDMESSAGE = qr<\012(EndMessage|Data)\012>;
122 127
123 # these are declared here for performance reasons 128 # these are declared here for performance reasons
124 my ($k, $v, $type); 129 my ($k, $v, $type);
185 190
186 $self->{hdl} = new AnyEvent::Handle 191 $self->{hdl} = new AnyEvent::Handle
187 connect => [$self->{host} => $self->{port}], 192 connect => [$self->{host} => $self->{port}],
188 timeout => $self->{timeout}, 193 timeout => $self->{timeout},
189 on_error => sub { 194 on_error => sub {
190 warn "@_\n";#d# 195 warn "$self->{host}: $_[2]\n";#d#
191 exit 1; 196 exit 1;
192 }, 197 },
193 on_read => $on_read, 198 on_read => $on_read,
194 on_eof => $self->{on_eof} || sub { }, 199 on_eof => $self->{on_eof} || sub { },
195 ; 200 ;

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines