Add disconnect() to Connection, using the CLS protocol command

Signed-off-by: Pedro Melo <melo@simplicidade.org>
This commit is contained in:
Pedro Melo
2014-07-20 22:12:14 +01:00
parent cbc2429862
commit 1b536cf011

View File

@@ -85,6 +85,21 @@ sub connect {
return;
}
sub disconnect {
my ($self, $cb) = @_;
return unless my $hdl = $self->{handle};
$hdl->push_write("CLS\012");
$self->_on_next_success_frame(
sub {
$cb->($self, @_) if $cb;
$self->_force_disconnect;
}
);
return;
}
## Protocol API