Merge branch 'dev' of github.com:emqtt/emqtt into dev

This commit is contained in:
Ery Lee 2015-01-12 19:33:17 +08:00
commit 7e6f817519
4 changed files with 27 additions and 9 deletions

View File

@ -140,13 +140,13 @@ terminate(Reason, #state{proto_state = unefined}) ->
io:format("client terminated: ~p, reason: ~p~n", [self(), Reason]), io:format("client terminated: ~p, reason: ~p~n", [self(), Reason]),
%%TODO: fix keep_alive... %%TODO: fix keep_alive...
%%emqtt_keep_alive:cancel(KeepAlive), %%emqtt_keep_alive:cancel(KeepAlive),
%emqtt_protocol:client_terminated(ProtoState), %emqtt_protocol:connection_lost(ProtoState),
ok; ok;
terminate(_Reason, #state { keepalive = KeepAlive, proto_state = ProtoState }) -> terminate(_Reason, #state { keepalive = KeepAlive, proto_state = ProtoState }) ->
%%TODO: fix keep_alive... %%TODO: fix keep_alive...
emqtt_keepalive:cancel(KeepAlive), emqtt_keepalive:cancel(KeepAlive),
emqtt_protocol:client_terminated(ProtoState), emqtt_protocol:connection_lost(ProtoState),
ok. ok.
code_change(_OldVsn, State, _Extra) -> code_change(_OldVsn, State, _Extra) ->

View File

@ -45,7 +45,7 @@
-export([initial_state/2]). -export([initial_state/2]).
-export([handle_packet/2, send_message/2, send_packet/2, client_terminated/1]). -export([handle_packet/2, send_message/2, send_packet/2, connection_lost/1]).
-export([info/1]). -export([info/1]).
@ -277,7 +277,7 @@ send_packet(Packet, #proto_state{socket = Sock, peer_name = PeerName, client_id
erlang:port_command(Sock, Data). erlang:port_command(Sock, Data).
%%TODO: fix me later... %%TODO: fix me later...
client_terminated(#proto_state{client_id = ClientId} = State) -> connection_lost(#proto_state{client_id = ClientId} = State) ->
ok. ok.
%emqtt_cm:unregister(ClientId, self()). %emqtt_cm:unregister(ClientId, self()).

View File

@ -53,7 +53,7 @@
-export([start_link/0]). -export([start_link/0]).
-export([create/2, resume/2, destroy/1]). -export([lookup/1, create/2, resume/2, destroy/1]).
%% ------------------------------------------------------------------ %% ------------------------------------------------------------------
%% gen_server Function Exports %% gen_server Function Exports
@ -62,12 +62,18 @@
-export([init/1, handle_call/3, handle_cast/2, handle_info/2, -export([init/1, handle_call/3, handle_cast/2, handle_info/2,
terminate/2, code_change/3]). terminate/2, code_change/3]).
-record(state, { expires = 24, %hours
max_queue = 1000 }).
%% ------------------------------------------------------------------ %% ------------------------------------------------------------------
%% API Function Definitions %% API Function Definitions
%% ------------------------------------------------------------------ %% ------------------------------------------------------------------
start_link() -> start_link(SessOpts) ->
gen_server:start_link({local, ?SERVER}, ?MODULE, [], []). gen_server:start_link({local, ?SERVER}, ?MODULE, [SessOpts], []).
lookup(ClientId) -> ok.
create(ClientId, Pid) -> ok. create(ClientId, Pid) -> ok.
@ -79,8 +85,12 @@ destroy(ClientId) -> ok.
%% gen_server Function Definitions %% gen_server Function Definitions
%% ------------------------------------------------------------------ %% ------------------------------------------------------------------
init(Args) -> init(SessOpts) ->
{ok, Args}. {ok, SessOpts} = application:get_env(session),
State = #state{ expires = proplists:get_value(expires, SessOpts, 24) * 3600,
max_queue = proplists:get_value(max_queue, SessOpts, 1000) },
{ok, State}.
handle_call(_Request, _From, State) -> handle_call(_Request, _From, State) ->
{reply, ok, State}. {reply, ok, State}.

View File

@ -33,6 +33,14 @@
]}, ]},
{emqtt, [ {emqtt, [
{auth, {anonymous, []}}, %internal, anonymous {auth, {anonymous, []}}, %internal, anonymous
{session, [
{expires, 24},
{max_queue, 1000},
{qos0, false}
]},
{retain, [
]},
{listen, [ {listen, [
{mqtt, 1883, [ {mqtt, 1883, [
{max_conns, 1024}, {max_conns, 1024},