aboutsummaryrefslogtreecommitdiffstats
path: root/src/cowboy_http_websocket_handler.erl
diff options
context:
space:
mode:
authorLoïc Hoguin <[email protected]>2011-09-15 23:13:27 +0200
committerLoïc Hoguin <[email protected]>2011-09-15 23:20:02 +0200
commit04f55eb3c925705da28b3509b2f7e6b203632391 (patch)
tree684b66874c527f95735205aeb9c52fc0daba95ff /src/cowboy_http_websocket_handler.erl
parent89ae3c8cadc6f1ce0a9b66ba5c2e3aa4834d4440 (diff)
downloadcowboy-04f55eb3c925705da28b3509b2f7e6b203632391.tar.gz
cowboy-04f55eb3c925705da28b3509b2f7e6b203632391.tar.bz2
cowboy-04f55eb3c925705da28b3509b2f7e6b203632391.zip
Allow websocket handlers to hibernate from the websocket_init/3 function
Also improve the documentation about hibernate.
Diffstat (limited to 'src/cowboy_http_websocket_handler.erl')
-rw-r--r--src/cowboy_http_websocket_handler.erl8
1 files changed, 6 insertions, 2 deletions
diff --git a/src/cowboy_http_websocket_handler.erl b/src/cowboy_http_websocket_handler.erl
index 90cf7ac..2ea0a46 100644
--- a/src/cowboy_http_websocket_handler.erl
+++ b/src/cowboy_http_websocket_handler.erl
@@ -29,8 +29,7 @@
%% here.
%%
%% <em>websocket_handle/3</em> receives the data from the socket. It can reply
-%% something, do nothing or close the connection. You can choose to hibernate
-%% the process by returning <em>hibernate</em> to save memory and CPU.
+%% something, do nothing or close the connection.
%%
%% <em>websocket_info/3</em> receives messages sent to the process. It has
%% the same reply format as <em>websocket_handle/3</em> described above. Note
@@ -41,6 +40,11 @@
%% <em>websocket_terminate/3</em> is meant for cleaning up. It also receives
%% the request and the state previously defined, along with a reason for
%% termination.
+%%
+%% All of <em>websocket_init/3</em>, <em>websocket_handle/3</em> and
+%% <em>websocket_info/3</em> can decide to hibernate the process by adding
+%% an extra element to the returned tuple, containing the atom
+%% <em>hibernate</em>. Doing so helps save memory and improve CPU usage.
-module(cowboy_http_websocket_handler).
-export([behaviour_info/1]).