AnyEvent-Campfire-Client

 view release on metacpan or  search on metacpan

examples/test.pl  view on Meta::CPAN

                        sub {
                            my ( $body, $hdr ) = @_;
                            if ( $hdr->{Status} !~ m/2/ ) {
                                $client->emit( 'error',
                                    "$hdr->{Status}: $hdr->{Reason}" );
                                $client->exit;
                            }
                            else {
                                print "$hdr->{Status}: unlocked room\n";
                                $client->exit;
                            }
                        }
                    );
                }
            }
        );

        #    $client->put_room('535881', encode_json({ room => { name => 'Room 1', topic => 'oops' } }), sub {
        #        my ($body, $hdr) = @_;
        #        if ($hdr->{Status} !~ m/2/) {
        #            $client->emit('error', "$hdr->{Status}: $hdr->{Reason}");
        #        } else {
        #            print "$hdr->{Status}: updated room\n";
        #        }
        #
        #        $client->exit;
        #    });
        #
        #    $client->get_rooms(sub {
        #        my ($body, $hdr) = @_;
        #        if ($hdr->{Status} !~ m/2/) {
        #            $client->emit('error', "$hdr->{Status}: $hdr->{Reason}");
        #        } else {
        #            $body = encode_json($body) if 'HASH' eq ref($body);
        #            print "$hdr->{Status}: $body\n";
        #        }
        #
        #        $client->exit;
        #    });
    }
);
$client->on( 'error', sub { print "ERROR: $_[1]\n" } );
$client->on(
    'leave',
    sub {
        my ( $e, $room ) = @_;
        print "leaved room($room)\n";
    }
);

$client->on( 'exit', sub { $cv->send } );

$cv->recv;

__END__

=pod

=head1 SYNOPSIS

    you> say hello
    bot> hello
    you> leave
    bot> has left the room.

=cut



( run in 0.578 second using v1.01-cache-2.11-cpan-d7a12ab2c7f )