Skip to content

Commit 22371b5

Browse files
author
no
committed
FIX: websocket_handle_event/3 signatures for websocket_open and websocket_close in elli_example_websocket.erl
In elli_example_websocket.erl: FIX: websocket_handle_event/3 signatures for websocket_open and websocket_close ADD: how-to comments in websocket_handle/3 for simple echo server implementation
1 parent db6b5ab commit 22371b5

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

src/elli_example_websocket.erl

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,11 @@ websocket_info(Req, Message, State) ->
9090

9191
websocket_handle(Req, Message, State) ->
9292
io:fwrite(standard_error, "example_ws_handle: ~p~n", [Message]),
93+
%% default behaviour.
9394
{ok, State}.
95+
%% comment the line above ({ok, State}.)
96+
%% and uncomment the line below for an echo server.
97+
% {reply, Message, State}.
9498

9599

96100
%%
@@ -99,8 +103,8 @@ websocket_handle(Req, Message, State) ->
99103

100104
%% websocket_open and websocket_close events are sent when the websocket
101105
%% opens, and when it closes.
102-
websocket_handle_event(websocket_open, [_Version, _Compress], _) -> ok;
103-
websocket_handle_event(websocket_close, [_Reason], _) -> ok;
106+
websocket_handle_event(websocket_open, [_, _Version, _Compress], _) -> ok;
107+
websocket_handle_event(websocket_close, [_, _Reason], _) -> ok;
104108

105109
%% websocket_throw, websocket_error and websocket_exit events are sent if
106110
%% the user callback code throws an exception, has an error or

0 commit comments

Comments
 (0)