ws_timeout_hibernate_handler.erl 743 B

1234567891011121314151617181920212223242526272829
  1. %% Feel free to use, reuse and abuse the code in this file.
  2. -module(ws_timeout_hibernate_handler).
  3. -behaviour(cowboy_http_handler).
  4. -behaviour(cowboy_http_websocket_handler).
  5. -export([init/3, handle/2, terminate/2]).
  6. -export([websocket_init/3, websocket_handle/3,
  7. websocket_info/3, websocket_terminate/3]).
  8. init(_Any, _Req, _Opts) ->
  9. {upgrade, protocol, cowboy_http_websocket}.
  10. handle(_Req, _State) ->
  11. exit(badarg).
  12. terminate(_Req, _State) ->
  13. exit(badarg).
  14. websocket_init(_TransportName, Req, _Opts) ->
  15. {ok, Req, undefined, 1000, hibernate}.
  16. websocket_handle(_Frame, Req, State) ->
  17. {ok, Req, State, hibernate}.
  18. websocket_info(_Info, Req, State) ->
  19. {ok, Req, State, hibernate}.
  20. websocket_terminate(_Reason, _Req, _State) ->
  21. ok.