Skip to content

Commit 5598b83

Browse files
author
HpyHacking
committed
use handler end of the query path
1 parent 4166613 commit 5598b83

File tree

3 files changed

+5
-12
lines changed

3 files changed

+5
-12
lines changed

examples/server.erl

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -6,21 +6,15 @@ main(_) ->
66
code:add_patha("ebin"),
77
code:add_patha("deps/mochiweb/ebin"),
88

9-
webtekcos_app:start(),
9+
application:start(sasl),
10+
application:start(webtekcos),
1011

1112
io:format("Open client.html test websocket server.~n"),
1213
io:format("It's listen on localhost:3008.~n"),
1314
io:format("Press Ctrl+C to shutdown server!!!~n"),
1415

1516
os:cmd("open ./examples"),
1617

17-
%webtekcos:start_link("127.0.0.1", 8000),
18-
%webtekcos_event_logger:add_handler(),
19-
20-
webtekcos_event_logger:add_handler(),
21-
22-
appmon:start(),
23-
2418
receive
2519
_ -> ok
2620
end.

src/webtekcos.erl

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -52,9 +52,8 @@ handshake(VersionMod, Socket, Headers) ->
5252
log([handshake_end, VersionMod]),
5353

5454
Path = webtekcos_tools:get_header(Headers, "_PATH_"),
55-
Mod = list_to_atom(string:join(string:tokens(Path, "/"), "_")),
56-
log([handle_mod, Mod]),
57-
55+
%% convert query path to end of "handler" mod name
56+
Mod = list_to_atom(string:join(string:tokens(Path, "/") ++ ["handler"], "_")),
5857
check_mod(Mod, VersionMod, Socket, undef).
5958

6059
check_mod(Mod, VersionMod, Socket, LoopData) ->
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
-module(webtekcos_sample).
1+
-module(webtekcos_sample_handler).
22
-export([connect/0, disconnect/1, handle_data/2, handle_message/2]).
33

44
connect() ->

0 commit comments

Comments
 (0)