diff --git a/README.md b/README.md index 6d7ad71..aa36ca7 100644 --- a/README.md +++ b/README.md @@ -111,9 +111,11 @@ simple. It has just a couple of methods: after the client was last connected (in ms). * `{response_limit, integer()}` - the maximum size of a single http streaming response (in bytes). - * `{hib_timeout, integer()}` - hibernate websocket process after - hib_timeout milliseconds of inactivity (5000 by default) to - reduce memory footprint. (implementation is incomplete, see #15) + * `{hib_timeout, integer() | hibernate}` - hibernate websocket + process after hib_timeout milliseconds of inactivity (5000 by + default) to reduce memory footprint. Set to 'hibernate' atom to + hibernate always (may be inefficient). (implementation is + incomplete, see #15) * `{logger, fun/3}` - a function called on every request, used to print request to the logs (or on the screen by default). diff --git a/src/sockjs_cowboy_handler.erl b/src/sockjs_cowboy_handler.erl index 4e827d7..630cdc8 100644 --- a/src/sockjs_cowboy_handler.erl +++ b/src/sockjs_cowboy_handler.erl @@ -73,6 +73,9 @@ websocket_terminate(_Reason, _Req, {RawWebsocket, SessionPid, _HT}) -> %% -------------------------------------------------------------------------- +mh({ok, Req, {RawWebsocket, SessionPid, {TRef, hibernate}}}) -> + {ok, Req, {RawWebsocket, SessionPid, {TRef, hibernate}}, hibernate}; + mh({ok, Req, {RawWebsocket, SessionPid, {TRef, HibTimeout}}}) -> case TRef of undefined -> ok;