diff options
author | Loïc Hoguin <[email protected]> | 2020-11-12 14:00:41 +0100 |
---|---|---|
committer | Loïc Hoguin <[email protected]> | 2020-11-12 14:00:41 +0100 |
commit | 4a58077d5162325fa5723690e58e7364adbcb18c (patch) | |
tree | 6f088a7a9b9d1f6b0eacdeb98de1eb5b8032b647 /src/gun.erl | |
parent | 1ebad8acf803eb797a6c61f6522ebc3b79f104a1 (diff) | |
download | gun-4a58077d5162325fa5723690e58e7364adbcb18c.tar.gz gun-4a58077d5162325fa5723690e58e7364adbcb18c.tar.bz2 gun-4a58077d5162325fa5723690e58e7364adbcb18c.zip |
Replace gun:ws_send/2 with gun:ws_send/3
Switching from /2 to /3 should be easy enough.
Also update the documentation about HTTP/2 Websocket support.
Diffstat (limited to 'src/gun.erl')
-rw-r--r-- | src/gun.erl | 18 |
1 files changed, 0 insertions, 18 deletions
diff --git a/src/gun.erl b/src/gun.erl index 97cd3c9..2966910 100644 --- a/src/gun.erl +++ b/src/gun.erl @@ -92,7 +92,6 @@ -export([ws_upgrade/2]). -export([ws_upgrade/3]). -export([ws_upgrade/4]). --export([ws_send/2]). -export([ws_send/3]). %% Internals. @@ -930,12 +929,6 @@ ws_upgrade(ServerPid, Path, Headers, Opts0) -> gen_statem:cast(ServerPid, {ws_upgrade, ReplyTo, StreamRef, Path, normalize_headers(Headers), Opts}), StreamRef. -%% @todo ws_send/2 will need to be deprecated in favor of a variant with StreamRef. -%% But it can be kept for the time being since it can still work for HTTP/1.1 (connected_ws_only). --spec ws_send(pid(), ws_frame() | [ws_frame()]) -> ok. -ws_send(ServerPid, Frames) -> - gen_statem:cast(ServerPid, {ws_send, self(), Frames}). - -spec ws_send(pid(), stream_ref(), ws_frame() | [ws_frame()]) -> ok. ws_send(ServerPid, StreamRef, Frames) -> gen_statem:cast(ServerPid, {ws_send, self(), StreamRef, Frames}). @@ -1219,11 +1212,6 @@ connected_ws_only(cast, {ws_send, ReplyTo, StreamRef, Frames}, State=#state{ ProtoState, dereference_stream_ref(StreamRef, State), ReplyTo, EvHandler, EvHandlerState0), commands(Commands, State#state{event_handler_state=EvHandlerState}); -connected_ws_only(cast, {ws_send, ReplyTo, Frames}, State=#state{ - protocol=Protocol=gun_ws, protocol_state=ProtoState, - event_handler=EvHandler, event_handler_state=EvHandlerState0}) -> - {Commands, EvHandlerState} = Protocol:ws_send(Frames, ProtoState, ReplyTo, EvHandler, EvHandlerState0), - commands(Commands, State#state{event_handler_state=EvHandlerState}); connected_ws_only(cast, Msg, _) when element(1, Msg) =:= headers; element(1, Msg) =:= request; element(1, Msg) =:= data; element(1, Msg) =:= connect; element(1, Msg) =:= ws_upgrade -> @@ -1309,12 +1297,6 @@ connected(cast, {ws_send, ReplyTo, StreamRef, Frames}, State=#state{ ProtoState, dereference_stream_ref(StreamRef, State), ReplyTo, EvHandler, EvHandlerState0), commands(Commands, State#state{event_handler_state=EvHandlerState}); -%% Catch-all for the StreamRef-free variant. -connected(cast, {ws_send, ReplyTo, _}, _) -> - ReplyTo ! {gun_error, self(), {badstate, - "Connection needs to be upgraded to Websocket " - "before the gun:ws_send/1 function can be used."}}, - keep_state_and_data; connected(Type, Event, State) -> handle_common_connected(Type, Event, ?FUNCTION_NAME, State). |