- $self->{oldstate} = $self->{state};
- $self->{state} = shift;
- dbg('state', "$self->{call} channel state $self->{oldstate} -> $self->{state}\n");
+ if (@_) {
+ $self->{oldstate} = $self->{state};
+ $self->{state} = shift;
+ dbg('state', "$self->{call} channel func $self->{func} state $self->{oldstate} -> $self->{state}\n");
+ }
+ return $self->{state};
+}
+
+# disconnect this channel
+sub disconnect
+{
+ my $self = shift;
+ my $user = $self->{user};
+ my $conn = $self->{conn};
+ $self->finish();
+ $user->close() if defined $user;
+ $conn->disconnect() if defined $conn;
+ $self->del();