Skip to content

Commit

Permalink
add frame method to Mojo::Transaction::WebSocket
Browse files Browse the repository at this point in the history
  • Loading branch information
kraih committed Jan 10, 2016
1 parent 065861e commit 8e54539
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
4 changes: 2 additions & 2 deletions lib/Mojo/Channel/WebSocket.pm
Expand Up @@ -12,10 +12,10 @@ sub read {
$self->{read} .= $chunk // '';
while (my $frame = parse_frame \$self->{read}, $tx->max_websocket_size) {
$tx->finish(1009) and last unless ref $frame;
$tx->emit(frame => $frame);
$tx->frame($frame);
}

$tx->emit('resume');
$tx->resume;
}


Expand Down
8 changes: 8 additions & 0 deletions lib/Mojo/Transaction/WebSocket.pm
Expand Up @@ -68,6 +68,8 @@ sub finish {
return $self;
}

sub frame { shift->emit(frame => shift) }

sub is_closing { !!shift->{closing} }

sub is_established { !!$_[0]{open} || !!$_[0]{masked} }
Expand Down Expand Up @@ -383,6 +385,12 @@ Connection identifier.
Close WebSocket connection gracefully.
=head2 frame
$ws->frame($frame);
Low-level signal that a WebSocket frame has been received.
=head2 is_closing
my $bool = $ws->is_closing;
Expand Down

0 comments on commit 8e54539

Please sign in to comment.