Skip to content

Instantly share code, notes, and snippets.

Created February 15, 2017 00:49
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save anonymous/c96e764801e9dfd45f8dfe517bb10be5 to your computer and use it in GitHub Desktop.
Save anonymous/c96e764801e9dfd45f8dfe517bb10be5 to your computer and use it in GitHub Desktop.
my $client = Mojo::IOLoop->client( { address => '127.0.0.1', port => 1000 } => sub {
my ( $client, $err, $stream ) = @_;
$stream->write( $event => sub {
say "event sent";
$stream->close;
$end->();
});
$stream->on(close => sub {
my $stream = shift;
say "eventd closed the connection";
$end->();
});
$stream->on(error => sub {
my ($stream, $err) = @_;
say "error sending event: $err";
$end->();
});
$stream->on(timeout => sub {
my $stream = shift;
say "timeout sending event";
$end->();
});
say $err if $err;
$end->();
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment