sub parse_packet {
my ($self,$data) = @_;
+ die "no data in packet" unless $data;
my ($magic, $type, $len) = unpack( "a4NN", $data );
die "wrong magic [$magic]" unless $magic eq "\0RES";
die "unsupported type [$type]" unless exists $nr2type->{$type};
my $response;
my $cb = sub {
my ( $self, $data ) = @_;
- warn "# <<<< ",dump($data);
my ( $type, @data ) = $self->parse_packet($data);
+ warn "# <<<< ", $nr2type->{$type}, " ",dump(@data);
if ( $type == $packet_type->{JOB_CREATED} ) {
push @{ $self->{_cb_queue} }, sub {
};
- $data .= "\0" if $data;
+# $data .= "\0" if $data;
my $len = length($data);
my $message = pack("a4NN", "\0REQ", $packet_type->{$type}, length $data ) . $data;
- warn "# >>>> ",dump($message);
+ warn "# >>>> $type ",dump($message);
my $mqueue = $self->{_message_queue} ||= [];
my $cqueue = $self->{_cb_queue} ||= [];
sub _on_error {
my ($self, $ioloop, $id, $error) = @_;
+ warn "ERROR: $error";
+
$self->error($error);
$self->_inform_queue;