From 4a58077d5162325fa5723690e58e7364adbcb18c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lo=C3=AFc=20Hoguin?= Date: Thu, 12 Nov 2020 14:00:41 +0100 Subject: 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. --- doc/src/manual/gun.ws_send.asciidoc | 25 ++++++++++++++++--------- 1 file changed, 16 insertions(+), 9 deletions(-) (limited to 'doc/src/manual') diff --git a/doc/src/manual/gun.ws_send.asciidoc b/doc/src/manual/gun.ws_send.asciidoc index b39f3f0..224472e 100644 --- a/doc/src/manual/gun.ws_send.asciidoc +++ b/doc/src/manual/gun.ws_send.asciidoc @@ -8,13 +8,14 @@ gun:ws_send - Send Websocket frames [source,erlang] ---- -ws_send(ConnPid, Frames) -> ok - -ConnPid :: pid() -Frames :: Frame | [Frame] -Frame :: close | ping | pong - | {text | binary | close | ping | pong, iodata()} - | {close, non_neg_integer(), iodata()} +ws_send(ConnPid, StreamRef, Frames) -> ok + +ConnPid :: pid() +StreamRef :: gun:stream_ref() +Frames :: Frame | [Frame] +Frame :: close | ping | pong + | {text | binary | close | ping | pong, iodata()} + | {close, non_neg_integer(), iodata()} ---- Send Websocket frames. @@ -28,6 +29,10 @@ ConnPid:: The pid of the Gun connection process. +StreamRef:: + +Identifier of the stream that was upgraded to Websocket. + Frames:: One or more Websocket frame(s). @@ -38,6 +43,8 @@ The atom `ok` is returned. == Changelog +* *2.0*: The mandatory `StreamRef` argument was added. +* *2.0*: It is now possible to send multiple frames at once. * *1.0*: Function introduced. == Examples @@ -45,13 +52,13 @@ The atom `ok` is returned. .Send a single frame [source,erlang] ---- -gun:ws_send(ConnPid, {text, <<"Hello world!">>}). +gun:ws_send(ConnPid, StreamRef, {text, <<"Hello world!">>}). ---- .Send many frames including a close frame [source,erlang] ---- -gun:ws_send(ConnPid, [ +gun:ws_send(ConnPid, StreamRef, [ {text, <<"See you later, world!">>}, close ]). -- cgit v1.2.3