Skip to content

Commit ca3331a

Browse files
committed
Merge tag '0.1.1' into develop
Support OTP 20 and 21 See #3 and #6.
2 parents 1a95393 + 3991c1c commit ca3331a

6 files changed

+26
-53
lines changed

Makefile

-36
This file was deleted.

doc/elli_ws_request_adapter.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,7 @@ upgrade_reply(X1::101, Headers::<a href="http://raw.github.com/elli-lib/elli/dev
134134
websocket_handler_callback(Req, Handler, Callback, Message, HandlerState) -&gt; Result
135135
</code></pre>
136136

137-
<ul class="definitions"><li><code>Req = <a href="#type-req">req()</a></code></li><li><code>Handler = module()</code></li><li><code>Callback = websocket_info | websocket_handle</code></li><li><code>Message = any()</code></li><li><code>HandlerState = any()</code></li><li><code>Result = {ok, <a href="#type-req">req()</a>, any()} | {ok, <a href="#type-req">req()</a>, any(), hibernate} | {reply, <a href="elli_websocket.md#type-payload">elli_websocket:payload()</a>, <a href="#type-req">req()</a>, any()} | {reply, <a href="elli_websocket.md#type-payload">elli_websocket:payload()</a>, hibernate, <a href="#type-req">req()</a>, any()} | {shutdown, <a href="#type-req">req()</a>, any()}</code></li></ul>
137+
<ul class="definitions"><li><code>Req = <a href="#type-req">req()</a></code></li><li><code>Handler = module()</code></li><li><code>Callback = websocket_info | websocket_handle</code></li><li><code>Message = any()</code></li><li><code>HandlerState = any()</code></li><li><code>Result = {ok, <a href="#type-req">req()</a>, any()} | {ok, <a href="#type-req">req()</a>, any(), hibernate} | {reply, <a href="elli_ws_protocol.md#type-frame">elli_ws_protocol:frame()</a> | [<a href="elli_ws_protocol.md#type-frame">elli_ws_protocol:frame()</a>], <a href="#type-req">req()</a>, any()} | {reply, <a href="elli_ws_protocol.md#type-frame">elli_ws_protocol:frame()</a> | [<a href="elli_ws_protocol.md#type-frame">elli_ws_protocol:frame()</a>], <a href="#type-req">req()</a>, any(), hibernate} | {shutdown, <a href="#type-req">req()</a>, any()}</code></li></ul>
138138

139139
Calls websocket_info en websocket_handle callbacks.
140140

rebar.config

+10-7
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
1-
{erl_opts, [debug_info]}.
1+
{erl_opts, [
2+
debug_info,
3+
{platform_define, "^2[1-9]", post20}
4+
]}.
25

3-
{xref_checks, [undefined_function_calls,locals_not_used]}.
6+
{xref_checks, [undefined_function_calls, locals_not_used]}.
47

58
{dialyzer, [{base_plt_apps, [elli]}]}.
69

@@ -9,11 +12,11 @@
912
{erl_first_files, [
1013
"src/elli_websocket_handler"
1114
]},
12-
{deps, [{elli, "2.0.1"}]}
15+
{deps, [{elli, "3.1.0"}]}
1316
]},
1417
{docs, [
1518
{deps, [
16-
{elli, "2.0.1"},
19+
{elli, "3.1.0"},
1720
{edown, "0.8.1"}
1821
]}
1922
]}
@@ -23,7 +26,7 @@
2326
{application, elli_websocket},
2427
{subpackages, false},
2528
{doclet, edown_doclet},
26-
{todo, true},
29+
{todo, true},
2730
{doc_path, [
2831
"http://raw.github.com/elli-lib/elli/develop/doc"
2932
]},
@@ -34,8 +37,8 @@
3437
]}.
3538

3639
{project_plugins, [
37-
{coveralls, "1.4.0"},
38-
{rebar3_lint, "0.1.9"}
40+
{coveralls, "1.5.0"},
41+
{rebar3_lint, "0.1.10"}
3942
]}.
4043

4144
{provider_hooks, [{pre, [{eunit, lint}]}]}.

src/elli_websocket.app.src

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{application, elli_websocket, [
22
{description, "Elli WebSocket Handler."},
3-
{vsn, "0.1.0"},
3+
{vsn, "0.1.1"},
44
{modules, []},
55
{registered, []},
66
{applications, [kernel, stdlib, elli]},

src/elli_ws_protocol.erl

+5-5
Original file line numberDiff line numberDiff line change
@@ -329,12 +329,12 @@ websocket_data(State, Req, HandlerState, Data) ->
329329
handler_before_loop(State, Req, HandlerState, Data).
330330

331331
%% Initialize or update fragmentation state.
332-
%% -spec websocket_data(#state{}, Req, any(),
333-
%% opcode(), non_neg_integer(), mask_key(), binary(), rsv(), 0 | 1)
334-
%% -> {ok, Req, cowboy_middleware:env()}
335-
%% | {suspend, module(), atom(), [any()]}
336-
%% when Req::elli_ws_request_adapter:req().
337332
%% The opcode is only included in the first frame fragment.
333+
-spec websocket_data(#state{}, Req, any(),
334+
opcode(), non_neg_integer(), mask_key(), binary(), rsv(), 0 | 1)
335+
-> {ok, Req, cowboy_middleware:env()}
336+
| {suspend, module(), atom(), [any()]}
337+
when Req::elli_ws_request_adapter:req().
338338
websocket_data(State=#state{frag_state=undefined}, Req, HandlerState,
339339
Opcode, Len, MaskKey, Data, Rsv, 0) ->
340340
websocket_payload(State#state{frag_state={nofin, Opcode, <<>>}},

src/elli_ws_request_adapter.erl

+9-3
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,13 @@
6666

6767
-type req() :: #req_adapter{}.
6868

69+
-ifdef(post20).
70+
-define(EXCEPTION(Class, Reason, Stacktrace), Class:Reason:Stacktrace).
71+
-define(GET_STACK(Stacktrace), Stacktrace).
72+
-else.
73+
-define(EXCEPTION(Class, Reason, _), Class:Reason).
74+
-define(GET_STACK(_), erlang:get_stacktrace()).
75+
-endif.
6976

7077
%%
7178
%%
@@ -233,10 +240,9 @@ websocket_handler_handle_event(#req_adapter{req=Req}, Handler, Name, EventArgs,
233240
try
234241
Handler:websocket_handle_event(Name, [Req|EventArgs], HandlerOpts)
235242
catch
236-
EvClass:EvError ->
243+
?EXCEPTION(EvClass, EvError, ST) ->
237244
error_logger:error_msg("~p:handle_event/3 crashed ~p:~p~n~p",
238-
[Handler, EvClass, EvError,
239-
erlang:get_stacktrace()])
245+
[Handler, EvClass, EvError, ?GET_STACK(ST)])
240246
end.
241247

242248
%% @doc Atoms used to identify messages in {active, once | true} mode.

0 commit comments

Comments
 (0)