| 1 | package DBGp::Client::AnyEvent; | ||
| 2 | |||
| 3 | use strict; | ||
| 4 | use warnings; | ||
| 5 | |||
| 6 | =head1 NAME | ||
| 7 | |||
| 8 | DBGp::Client::AnyEvent - AnyEvent-based client for the DBGp debugger protocol | ||
| 9 | |||
| 10 | =head1 SYNOPSIS | ||
| 11 | |||
| 12 | $connected = AnyEvent->condvar; | ||
| 13 | $listener = DBGp::Client::AnyEvent::Listener->new( | ||
| 14 | port => 9000, | ||
| 15 | on_connection => sub { $connected->send($_[0]) }, | ||
| 16 | ); | ||
| 17 | $listener->listen; | ||
| 18 | |||
| 19 | $client = $connected->recv; | ||
| 20 | $client->on_stream(sub { | ||
| 21 | printf "Output from process (%s)\n---\n%s\n---\n", | ||
| 22 | $_[0]->type, $_[0]->content; | ||
| 23 | }); | ||
| 24 | $wait_res = $client->send_command( | ||
| 25 | undef, # no callback | ||
| 26 | 'breakpoint_set', '-t', 'conditional', | ||
| 27 | '-f', 'file:///path/to/file.pl', | ||
| 28 | '-n', $line, | ||
| 29 | '--', | ||
| 30 | encode_base64("$command; 0"), | ||
| 31 | ); | ||
| 32 | $res = $wait_res->recv; | ||
| 33 | die $res->message if $res->is_error; | ||
| 34 | |||
| 35 | # send and receive other commands | ||
| 36 | |||
| 37 | =head1 DESCRIPTION | ||
| 38 | |||
| 39 | A thin L<AnyEvent> wrapper on top of L<DBGp::Client>. | ||
| 40 | |||
| 41 | =cut | ||
| 42 | |||
| 43 | our $VERSION = '0.05'; | ||
| 44 | |||
| 45 | 1; | ||
| 46 | |||
| 47 | __END__ |