Merge branch 'dev' of github.com:emqtt/emqtt into dev
This commit is contained in:
commit
7e6f817519
|
@ -140,13 +140,13 @@ terminate(Reason, #state{proto_state = unefined}) ->
|
|||
io:format("client terminated: ~p, reason: ~p~n", [self(), Reason]),
|
||||
%%TODO: fix keep_alive...
|
||||
%%emqtt_keep_alive:cancel(KeepAlive),
|
||||
%emqtt_protocol:client_terminated(ProtoState),
|
||||
%emqtt_protocol:connection_lost(ProtoState),
|
||||
ok;
|
||||
|
||||
terminate(_Reason, #state { keepalive = KeepAlive, proto_state = ProtoState }) ->
|
||||
%%TODO: fix keep_alive...
|
||||
emqtt_keepalive:cancel(KeepAlive),
|
||||
emqtt_protocol:client_terminated(ProtoState),
|
||||
emqtt_protocol:connection_lost(ProtoState),
|
||||
ok.
|
||||
|
||||
code_change(_OldVsn, State, _Extra) ->
|
||||
|
|
|
@ -45,7 +45,7 @@
|
|||
|
||||
-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]).
|
||||
|
||||
|
@ -277,7 +277,7 @@ send_packet(Packet, #proto_state{socket = Sock, peer_name = PeerName, client_id
|
|||
erlang:port_command(Sock, Data).
|
||||
|
||||
%%TODO: fix me later...
|
||||
client_terminated(#proto_state{client_id = ClientId} = State) ->
|
||||
connection_lost(#proto_state{client_id = ClientId} = State) ->
|
||||
ok.
|
||||
%emqtt_cm:unregister(ClientId, self()).
|
||||
|
||||
|
|
|
@ -53,7 +53,7 @@
|
|||
|
||||
-export([start_link/0]).
|
||||
|
||||
-export([create/2, resume/2, destroy/1]).
|
||||
-export([lookup/1, create/2, resume/2, destroy/1]).
|
||||
|
||||
%% ------------------------------------------------------------------
|
||||
%% gen_server Function Exports
|
||||
|
@ -62,12 +62,18 @@
|
|||
-export([init/1, handle_call/3, handle_cast/2, handle_info/2,
|
||||
terminate/2, code_change/3]).
|
||||
|
||||
-record(state, { expires = 24, %hours
|
||||
max_queue = 1000 }).
|
||||
|
||||
|
||||
%% ------------------------------------------------------------------
|
||||
%% API Function Definitions
|
||||
%% ------------------------------------------------------------------
|
||||
|
||||
start_link() ->
|
||||
gen_server:start_link({local, ?SERVER}, ?MODULE, [], []).
|
||||
start_link(SessOpts) ->
|
||||
gen_server:start_link({local, ?SERVER}, ?MODULE, [SessOpts], []).
|
||||
|
||||
lookup(ClientId) -> ok.
|
||||
|
||||
create(ClientId, Pid) -> ok.
|
||||
|
||||
|
@ -79,8 +85,12 @@ destroy(ClientId) -> ok.
|
|||
%% gen_server Function Definitions
|
||||
%% ------------------------------------------------------------------
|
||||
|
||||
init(Args) ->
|
||||
{ok, Args}.
|
||||
init(SessOpts) ->
|
||||
{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) ->
|
||||
{reply, ok, State}.
|
||||
|
|
|
@ -33,6 +33,14 @@
|
|||
]},
|
||||
{emqtt, [
|
||||
{auth, {anonymous, []}}, %internal, anonymous
|
||||
{session, [
|
||||
{expires, 24},
|
||||
{max_queue, 1000},
|
||||
{qos0, false}
|
||||
]},
|
||||
{retain, [
|
||||
|
||||
]},
|
||||
{listen, [
|
||||
{mqtt, 1883, [
|
||||
{max_conns, 1024},
|
||||
|
|
Loading…
Reference in New Issue