-
-
Save anonymous/1ea128cd6f765adc8095ec8d91cc9a87 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
my $delay = Mojo::IOLoop::Delay->new; | |
my $client = Mojo::IOLoop::Client->new; | |
Mojo::IOLoop::Delay->new->steps( | |
sub { | |
my $delay = shift; | |
for (65000 .. 65100) { | |
send_event($delay, $client, $_); | |
} | |
} | |
); | |
sub send_event { | |
my ( $delay, $client, $port ) = @_; | |
my $event = "test 123"; | |
my $end = $delay->begin; | |
$client->on ( connect => sub { | |
my ( $client, $handle ) = @_; | |
$client->write ( $event ); | |
$end->(); | |
}); | |
$client->on ( error => sub { | |
my ( $client, $err ) = @_; | |
say "$err->{code} response: $err->{message}" if $err->{code}; | |
say "Connection error: $err->{message}"; | |
$end->(); | |
}); | |
$client->connect(address => '127.0.0.1', port => $port); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment