<html><head><meta name="color-scheme" content="light dark"></head><body><pre style="word-wrap: break-word; white-space: pre-wrap;">package Responder;

sub new {
	my $class = shift;

	my $self = {
		_env =&gt; shift,
		_counter =&gt; 0,
		_fd =&gt; -1,
	};

	bless $self, $class;

	return $self;
}

sub getline {
	my $self = shift;

	if ($self-&gt;{_counter} &gt; 10) {
		return undef;
	}
	elsif ($self-&gt;{_counter} == 3) {
		$self-&gt;{_counter}++;
		$self-&gt;{_fd} = uwsgi::async_connect("81.174.68.52:80");
		return uwsgi::wait_fd_write($self-&gt;{_fd}, 3);
	}
	elsif ($self-&gt;{_counter} == 4) {
		$self-&gt;{_counter}++;
		return "connected to http://projects.unbit.it&lt;br/&gt;";
	}
	elsif ($self-&gt;{_counter} == 7) {
		$self-&gt;{_counter}++;
		print "suspending the app...\n";
		uwsgi::async_sleep(3);
		uwsgi::suspend();
		print "resumed the app\n";
		return "Suspended and Resumed the app&lt;br/&gt;";
	}
	elsif ($self-&gt;{_counter} % 2 == 0) {
		$self-&gt;{_counter}++;
		print "sleeping...\n";
		return uwsgi::async_sleep(1);
	}
	else {
		$self-&gt;{_counter}++;
		return "Hello World ".$self-&gt;{_counter}."&lt;br/&gt;";
	}
}

sub close {
	my $self = shift;
	uwsgi::log("goodbye...\n");
}

1
</pre></body></html>