diff options
author | Loïc Hoguin <[email protected]> | 2022-12-05 17:22:09 +0100 |
---|---|---|
committer | Loïc Hoguin <[email protected]> | 2022-12-05 17:22:09 +0100 |
commit | 172800967c2d53251d7cb1015e3c957c5b065bb1 (patch) | |
tree | 1ce8a3d138b1ca7894ddd965c186b313aa0aaee4 /doc/src/manual/gun.ws_upgrade.asciidoc | |
parent | c98c045affe053ba37e062e2754f32dcd65a0b30 (diff) | |
download | gun-172800967c2d53251d7cb1015e3c957c5b065bb1.tar.gz gun-172800967c2d53251d7cb1015e3c957c5b065bb1.tar.bz2 gun-172800967c2d53251d7cb1015e3c957c5b065bb1.zip |
Document Websocket subprotocol negotiation
Diffstat (limited to 'doc/src/manual/gun.ws_upgrade.asciidoc')
-rw-r--r-- | doc/src/manual/gun.ws_upgrade.asciidoc | 21 |
1 files changed, 19 insertions, 2 deletions
diff --git a/doc/src/manual/gun.ws_upgrade.asciidoc b/doc/src/manual/gun.ws_upgrade.asciidoc index b553f3b..c6e3850 100644 --- a/doc/src/manual/gun.ws_upgrade.asciidoc +++ b/doc/src/manual/gun.ws_upgrade.asciidoc @@ -20,7 +20,7 @@ ws_upgrade(ConnPid, Path, Headers, WsOpts) ConnPid :: pid() Path :: iodata() Headers :: gun:req_headers() -WsOpts :: gun:ws_opts +WsOpts :: gun:ws_opts() StreamRef :: gun:stream_ref() ---- @@ -39,6 +39,11 @@ Gun does not currently support Websocket over HTTP/2. By default Gun will take the Websocket options from the connection's `ws_opts`. +Websocket subprotocol negotiation is enabled when +the `protocols` option is given. It takes a subprotocol +name and a module implementing the +link:man:gun_ws_protocol(3)[gun_ws_protocol(3)] behavior. + == Arguments ConnPid:: @@ -92,9 +97,21 @@ StreamRef = gun:ws_upgrade(ConnPid, "/ws", [], #{ }). ---- +.Upgrade to Websocket with protocol negotiation +[source,erlang] +---- +StreamRef = gun:ws_upgrade(ConnPid, "/ws", [], #{ + protocols => [ + {<<"mqtt">>, gun_ws_mqtt_h}, + {<<"v12.stomp">>, gun_ws_stomp_h} + ] +}). +---- + == See also link:man:gun(3)[gun(3)], link:man:gun:ws_send(3)[gun:ws_send(3)], link:man:gun_upgrade(3)[gun_upgrade(3)], -link:man:gun_ws(3)[gun_ws(3)] +link:man:gun_ws(3)[gun_ws(3)], +link:man:gun_ws_protocol(3)[gun_ws_protocol(3)] |