Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Newer
Older
100644 29 lines (22 sloc) 0.546 kB
5b0127b @rcaputo Remove emit() from roles.
authored
1 # vim: ts=2 sw=2 noexpandtab
36c08bd @rcaputo Add a strawman tcp client implementation.
authored
2 # A TCP echo client.
3 # Strawman use cases for Reflex::Stream and Reflex::Connector.
4
5c01112 @rcaputo Try to resolve on_my_foo not looking right. See eg 35 for newness.
authored
5 use lib qw(../lib);
36c08bd @rcaputo Add a strawman tcp client implementation.
authored
6
7 {
8 package TcpEchoClient;
9 use Moose;
f4b9817 @rcaputo Abstract the client code into Reflex::Client. Update eg 35 to use it.
authored
10 extends 'Reflex::Client';
36c08bd @rcaputo Add a strawman tcp client implementation.
authored
11
d80166b @rcaputo Use "handles" and rethrow subs to flatten Reflex::Client's API.
authored
12 sub on_client_connected {
5c57d49 @rcaputo !!! Experiment with Reflex events being objects.
authored
13 my ($self, $socket) = @_;
eb5cc0f @rcaputo Reflex::Collection manages a collection of objects so you don't have to.
authored
14 $self->connection()->put("Hello, world!\n");
f4b9817 @rcaputo Abstract the client code into Reflex::Client. Update eg 35 to use it.
authored
15 };
36c08bd @rcaputo Add a strawman tcp client implementation.
authored
16
9f89460 @rcaputo Get Reflex::Client working with new role-based Connector and Stream.
authored
17 sub on_connection_data {
5c57d49 @rcaputo !!! Experiment with Reflex events being objects.
authored
18 my ($self, $data) = @_;
19 warn $self;
f4b9817 @rcaputo Abstract the client code into Reflex::Client. Update eg 35 to use it.
authored
20 # Not chomped.
5c57d49 @rcaputo !!! Experiment with Reflex events being objects.
authored
21 warn "got from server: ", $data->octets();
36c08bd @rcaputo Add a strawman tcp client implementation.
authored
22
6c37951 @rcaputo Clean up the client cleanup a little.
authored
23 # Disconnect after we receive the echo.
24 $self->stop();
36c08bd @rcaputo Add a strawman tcp client implementation.
authored
25 }
26 }
27
9f89460 @rcaputo Get Reflex::Client working with new role-based Connector and Stream.
authored
28 TcpEchoClient->new(port => 12345)->run_all();
Something went wrong with that request. Please try again.