| 1 |
%% Feel free to use, reuse and abuse the code in this file. |
| 2 |
|
| 3 |
-module(ws_subprotocol). |
| 4 |
|
| 5 |
-export([init/2]). |
| 6 |
-export([websocket_handle/2]). |
| 7 |
-export([websocket_info/2]). |
| 8 |
|
| 9 |
init(Req, Opts) -> |
| 10 |
[Protocol | _] = cowboy_req:parse_header(<<"sec-websocket-protocol">>, Req), |
| 11 |
Req2 = cowboy_req:set_resp_header(<<"sec-websocket-protocol">>, Protocol, Req), |
| 12 |
{cowboy_websocket, Req2, Opts, #{ |
| 13 |
idle_timeout => 1000 |
| 14 |
}}. |
| 15 |
|
| 16 |
websocket_handle(_Frame, State) -> |
| 17 |
{ok, State}. |
| 18 |
|
| 19 |
websocket_info(_Info, State) -> |
| 20 |
{ok, State}. |