mirror of
https://github.com/ninenines/cowboy.git
synced 2025-07-15 12:40:25 +00:00
Add more frame types available in websocket replies
We can now reply empty close, ping and pong frames, or close frames with a payload. This means that we can send a frame and then close the connection in a single operation. If a close packet is sent, the connection is closed immediately, even if there was frames that remained to be sent. Cowboy will silently drop any extra frames in the list given as a reply.
This commit is contained in:
parent
3e0e507311
commit
067958abd2
4 changed files with 140 additions and 27 deletions
|
@ -50,7 +50,6 @@
|
|||
|
||||
-type opts() :: any().
|
||||
-type state() :: any().
|
||||
-type payload() :: {text | binary | ping | pong, binary()}.
|
||||
-type terminate_reason() :: {normal, closed}
|
||||
| {normal, timeout}
|
||||
| {error, closed}
|
||||
|
@ -67,15 +66,15 @@
|
|||
-callback websocket_handle({text | binary | ping | pong, binary()}, Req, State)
|
||||
-> {ok, Req, State}
|
||||
| {ok, Req, State, hibernate}
|
||||
| {reply, payload() | [payload()], Req, State}
|
||||
| {reply, payload() | [payload()], Req, State, hibernate}
|
||||
| {reply, cowboy_websocket:frame() | [cowboy_websocket:frame()], Req, State}
|
||||
| {reply, cowboy_websocket:frame() | [cowboy_websocket:frame()], Req, State, hibernate}
|
||||
| {shutdown, Req, State}
|
||||
when Req::cowboy_req:req(), State::state().
|
||||
-callback websocket_info(any(), Req, State)
|
||||
-> {ok, Req, State}
|
||||
| {ok, Req, State, hibernate}
|
||||
| {reply, payload() | [payload()], Req, State}
|
||||
| {reply, payload() | [payload()], Req, State, hibernate}
|
||||
| {reply, cowboy_websocket:frame() | [cowboy_websocket:frame()], Req, State}
|
||||
| {reply, cowboy_websocket:frame() | [cowboy_websocket:frame()], Req, State, hibernate}
|
||||
| {shutdown, Req, State}
|
||||
when Req::cowboy_req:req(), State::state().
|
||||
-callback websocket_terminate(terminate_reason(), cowboy_req:req(), state())
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue