blob: c2e1eaee0271dc81cd2d0db9323f8c2c6f6757df (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
|
package Responder;
sub new {
my $class = shift;
my $self = {
_env => shift,
_counter => 0,
_fd => -1,
};
bless $self, $class;
return $self;
}
sub getline {
my $self = shift;
if ($self->{_counter} > 10) {
return undef;
}
elsif ($self->{_counter} == 3) {
$self->{_counter}++;
$self->{_fd} = uwsgi::async_connect("81.174.68.52:80");
return uwsgi::wait_fd_write($self->{_fd}, 3);
}
elsif ($self->{_counter} == 4) {
$self->{_counter}++;
return "connected to https://projects.unbit.it<br/>";
}
elsif ($self->{_counter} == 7) {
$self->{_counter}++;
print "suspending the app...\n";
uwsgi::async_sleep(3);
uwsgi::suspend();
print "resumed the app\n";
return "Suspended and Resumed the app<br/>";
}
elsif ($self->{_counter} % 2 == 0) {
$self->{_counter}++;
print "sleeping...\n";
return uwsgi::async_sleep(1);
}
else {
$self->{_counter}++;
return "Hello World ".$self->{_counter}."<br/>";
}
}
sub close {
my $self = shift;
uwsgi::log("goodbye...\n");
}
1
|