Tidy identify, single write with all the data

Signed-off-by: Pedro Melo <melo@simplicidade.org>
This commit is contained in:
Pedro Melo
2014-07-20 17:45:30 +01:00
parent 28c97bd0a4
commit 88b263f0d5

View File

@@ -86,13 +86,12 @@ sub connect {
sub identify { sub identify {
my ($self, @rest) = @_; my ($self, @rest) = @_;
my $cb = pop @rest;
return unless my $hdl = $self->{handle}; return unless my $hdl = $self->{handle};
my $cb = pop @rest;
my $data = JSON::XS::encode_json($self->_build_identity_payload(@rest)); my $data = JSON::XS::encode_json($self->_build_identity_payload(@rest));
$hdl->push_write("IDENTIFY\012"); $hdl->push_write("IDENTIFY\012" . pack('N', length($data)) . $data);
$hdl->push_write(pack('N', length($data)));
$hdl->push_write($data);
$self->_on_next_success_frame(sub { $cb->($self, $self->{identify_info} = $_[1]) }); $self->_on_next_success_frame(sub { $cb->($self, $self->{identify_info} = $_[1]) });