Skip to content

Commit

Permalink
the resume method belongs to Mojo::Transaction::HTTP
Browse files Browse the repository at this point in the history
  • Loading branch information
kraih committed Jan 12, 2016
1 parent 0d1365a commit 6b2b39e
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 26 deletions.
17 changes: 0 additions & 17 deletions lib/Mojo/Transaction.pm
Expand Up @@ -41,8 +41,6 @@ sub remote_address {
: $self->original_remote_address;
}

sub resume { ++$_[0]{writing} and return $_[0]->emit('resume') }

sub server_close { shift->completed->emit('finish') }

sub server_read { croak 'Method "server_read" not implemented by subclass' }
Expand Down Expand Up @@ -96,15 +94,6 @@ Emitted when a connection has been assigned to transaction.
Emitted when transaction is finished.
=head2 resume
$tx->on(resume => sub {
my $tx = shift;
...
});
Emitted when transaction is resumed.
=head1 ATTRIBUTES
L<Mojo::Transaction> implements the following attributes.
Expand Down Expand Up @@ -225,12 +214,6 @@ Check if transaction is finished.
False, this is not a L<Mojo::Transaction::WebSocket> object.
=head2 resume
$tx = $tx->resume;
Resume transaction.
=head2 remote_address
my $address = $tx->remote_address;
Expand Down
17 changes: 17 additions & 0 deletions lib/Mojo/Transaction/HTTP.pm
Expand Up @@ -65,6 +65,8 @@ sub redirects {
return \@redirects;
}

sub resume { ++$_[0]{writing} and return $_[0]->emit('resume') }

sub server_read {
my ($self, $chunk) = @_;

Expand Down Expand Up @@ -221,6 +223,15 @@ Emitted when a request is ready and needs to be handled.
$tx->res->headers->header('X-Bender' => 'Bite my shiny metal ass!');
});
=head2 resume
$tx->on(resume => sub {
my $tx = shift;
...
});
Emitted when transaction is resumed.
=head2 unexpected
$tx->on(unexpected => sub {
Expand Down Expand Up @@ -300,6 +311,12 @@ transaction.
# Paths of all previous requests
say $_->req->url->path for @{$tx->redirects};
=head2 resume
$tx = $tx->resume;
Resume transaction.
=head2 server_read
$tx->server_read($bytes);
Expand Down
19 changes: 10 additions & 9 deletions lib/Mojo/Transaction/WebSocket.pm
Expand Up @@ -64,8 +64,6 @@ sub finish {
return $self;
}

sub is_established { !!shift->established }

sub is_websocket {1}

sub kept_alive { shift->handshake->kept_alive }
Expand Down Expand Up @@ -98,7 +96,7 @@ sub send {
$self->once(drain => $cb) if $cb;
$msg = $self->build_message($msg) unless ref $msg eq 'ARRAY';
$self->{write} .= Mojo::WebSocket::build_frame($self->masked, @$msg);
return $self->SUPER::resume;
return $self->emit('resume');
}

sub server_close {
Expand Down Expand Up @@ -317,6 +315,15 @@ least one subscriber.
say "Message: $msg";
});
=head2 resume
$tx->on(resume => sub {
my $tx = shift;
...
});
Emitted when transaction is resumed.
=head2 text
$ws->on(text => sub {
Expand Down Expand Up @@ -414,12 +421,6 @@ Connection identifier.
Close WebSocket connection gracefully.
=head2 is_established
my $bool = $ws->is_established;
Check if WebSocket connection has been established yet.
=head2 is_websocket
my $bool = $ws->is_websocket;
Expand Down

0 comments on commit 6b2b39e

Please sign in to comment.