Skip to content
This repository was archived by the owner on Nov 7, 2018. It is now read-only.

Commit 435e2dd

Browse files
leandrosilvadavebryson
authored andcommitted
now path isn't hardcoded
1 parent 24c4a0c commit 435e2dd

File tree

1 file changed

+7
-5
lines changed

1 file changed

+7
-5
lines changed

src/websocket_client.erl

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
-behaviour(gen_server).
1414

1515
%% API
16-
-export([start/3,write/1,close/0]).
16+
-export([start/3,start/4,write/1,close/0]).
1717

1818
%% gen_server callbacks
1919
-export([init/1, handle_call/3, handle_cast/2, handle_info/2,
@@ -35,15 +35,17 @@ behaviour_info(_) ->
3535
-record(state, {socket,readystate=undefined,headers=[],callback}).
3636

3737
start(Host,Port,Mod) ->
38-
gen_server:start_link({local, ?MODULE}, ?MODULE, [{Host,Port,Mod}], []).
38+
start(Host,Port,"/",Mod).
39+
40+
start(Host,Port,Path,Mod) ->
41+
gen_server:start_link({local, ?MODULE}, ?MODULE, [{Host,Port,Path,Mod}], []).
3942

4043
init(Args) ->
4144
process_flag(trap_exit,true),
42-
[{Host,Port,Mod}] = Args,
45+
[{Host,Port,Path,Mod}] = Args,
4346
{ok, Sock} = gen_tcp:connect(Host,Port,[binary,{packet, 0},{active,true}]),
4447

45-
%% Hardcoded path for now...
46-
Req = initial_request(Host,"/"),
48+
Req = initial_request(Host,Path),
4749
ok = gen_tcp:send(Sock,Req),
4850
inet:setopts(Sock, [{packet, http}]),
4951

0 commit comments

Comments
 (0)