forked from cybergrind/rebar-templates
-
Notifications
You must be signed in to change notification settings - Fork 1
/
cowboy_websocket.erl
46 lines (38 loc) · 1.56 KB
/
cowboy_websocket.erl
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
%%%-------------------------------------------------------------------
%%% @author {{author_name}} <author_email>
%%% @copyright (C) {{copyright_year}}, {{copyright_owner}}
%%% @doc
%%%
%%% @end
%%% Created : {{now_ts}} by {{author_name}} <author_email>
%%%-------------------------------------------------------------------
-module('{{handlerid}}_websocket').
%%%===================================================================
%% API
%%%===================================================================
export([]).
%%%===================================================================
%% Cowboy websocket handler callbacks
%%%===================================================================
-export([init/2,
websocket_handle/3,
websocket_info/3]).
%%%===================================================================
%%% API
%%%===================================================================
%%%===================================================================
%%% Cowboy websocket handler callbacks
%%%===================================================================
init(Req, Opts) ->
{cowboy_websocket, Req, Opts}.
websocket_handle(Data, Req, State) ->
{reply, Data, Req, State};
websocket_handle(_Data, Req, State) ->
{ok, Req, State}.
websocket_info(Data, Req, State) ->
{reply, {text, Msg}, Req, State};
websocket_info(_Info, Req, State) ->
{ok, Req, State}.
%%%===================================================================
%%% Internal functions
%%%===================================================================