2011-12-24 00:58:03 +01:00
|
|
|
%% Feel free to use, reuse and abuse the code in this file.
|
|
|
|
|
2013-04-22 15:55:22 +02:00
|
|
|
-module(ws_echo).
|
2011-12-24 00:58:03 +01:00
|
|
|
|
2014-09-26 15:58:44 +03:00
|
|
|
-export([init/2]).
|
|
|
|
-export([websocket_handle/3]).
|
|
|
|
-export([websocket_info/3]).
|
2011-12-24 00:58:03 +01:00
|
|
|
|
2014-09-26 15:58:44 +03:00
|
|
|
init(Req, _) ->
|
2014-09-30 20:12:13 +03:00
|
|
|
{cowboy_websocket, Req, undefined}.
|
2011-12-24 00:58:03 +01:00
|
|
|
|
|
|
|
websocket_handle({text, Data}, Req, State) ->
|
|
|
|
{reply, {text, Data}, Req, State};
|
|
|
|
websocket_handle({binary, Data}, Req, State) ->
|
|
|
|
{reply, {binary, Data}, Req, State};
|
|
|
|
websocket_handle(_Frame, Req, State) ->
|
|
|
|
{ok, Req, State}.
|
|
|
|
|
|
|
|
websocket_info(_Info, Req, State) ->
|
|
|
|
{ok, Req, State}.
|