aboutsummaryrefslogtreecommitdiffstats
path: root/test/handlers/ws_ping_h.erl
blob: a5848fedf066ecfbcfb960abd689c7e9039374c3 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
%% This module sends an empty ping to the client and
%% waits for a pong before sending a text frame. It
%% is used to confirm server-initiated pings work.

-module(ws_ping_h).
-behavior(cowboy_websocket).

-export([init/2]).
-export([websocket_init/1]).
-export([websocket_handle/2]).
-export([websocket_info/2]).

init(Req, _) ->
	{cowboy_websocket, Req, undefined}.

websocket_init(State) ->
	{[{ping, <<>>}], State}.

websocket_handle(pong, State) ->
	{[{text, <<"OK!!">>}], State}.

websocket_info(_, State) ->
	{[], State}.