Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Newer
Older
100644 36 lines (27 sloc) 1.056 kB
5b0127b @rcaputo Remove emit() from roles.
authored
1 # vim: ts=2 sw=2 noexpandtab
ca75de2 @rcaputo Sanitize (as in make SANE) Reflex::Stream callback names.
authored
2 use lib qw(../lib);
3
b1d4291 @rcaputo Begin exploring parameterized Moose roles for static composition.
authored
4 use Moose;
5 use Socket qw(AF_UNIX SOCK_STREAM PF_UNSPEC);
6 use Proxy;
08bafbd @rcaputo Massive redoing of Reflex roles and some of the objects that use them.
authored
7 use Reflex::Stream;
e64e2b5 @rcaputo Reify the Streamable role as a Stream object.
authored
8
c5e0e08 @rcaputo Get the Stream/Proxy example working.
authored
9 # Socket pair 1. Writes to either end are readable at the other.
e64e2b5 @rcaputo Reify the Streamable role as a Stream object.
authored
10 my ($socket_1a, $socket_1b);
11 socketpair($socket_1a, $socket_1b, AF_UNIX, SOCK_STREAM, PF_UNSPEC) or die $!;
b1d4291 @rcaputo Begin exploring parameterized Moose roles for static composition.
authored
12
c5e0e08 @rcaputo Get the Stream/Proxy example working.
authored
13 # Socket pair 2. Writes to either end are readable at the other.
e64e2b5 @rcaputo Reify the Streamable role as a Stream object.
authored
14 my ($socket_2a, $socket_2b);
15 socketpair($socket_2a, $socket_2b, AF_UNIX, SOCK_STREAM, PF_UNSPEC) or die $!;
b1d4291 @rcaputo Begin exploring parameterized Moose roles for static composition.
authored
16
c5e0e08 @rcaputo Get the Stream/Proxy example working.
authored
17 # Proxy. Data appearing at either end is written to the other.
b1d4291 @rcaputo Begin exploring parameterized Moose roles for static composition.
authored
18 my $p = Proxy->new(
9479f27 @rcaputo Experimentally coerce callbacks from contextual parameters.
authored
19 client => $socket_1b,
20 server => $socket_2b,
b1d4291 @rcaputo Begin exploring parameterized Moose roles for static composition.
authored
21 );
22
08bafbd @rcaputo Massive redoing of Reflex roles and some of the objects that use them.
authored
23 my $s1 = Reflex::Stream->new( handle => $socket_1a );
24 my $s2 = Reflex::Stream->new( handle => $socket_2a );
e64e2b5 @rcaputo Reify the Streamable role as a Stream object.
authored
25
26 # Write data to Socket 1a.
c5e0e08 @rcaputo Get the Stream/Proxy example working.
authored
27 # It will appear on Socket 1b, via the socketpair.
28 # Proxy will write it to Socket 2b.
29 # The data will emerge on Socket 2a, via the other socketpair.
30
e64e2b5 @rcaputo Reify the Streamable role as a Stream object.
authored
31 $s1->put("test request\n");
b1d4291 @rcaputo Begin exploring parameterized Moose roles for static composition.
authored
32
c5e0e08 @rcaputo Get the Stream/Proxy example working.
authored
33 # Wait for it to arrive on Stream 2 (socket 2a).
5f9458c @rcaputo Rename observe() to watch(). Rename wait() to next().
authored
34 my $e = $s2->next();
5c57d49 @rcaputo !!! Experiment with Reflex events being objects.
authored
35 warn "Got: ", $e->_name(), ": ", $e->octets();
Something went wrong with that request. Please try again.