publish willmsg when normal exit
This commit is contained in:
parent
30ff3b3f4e
commit
7bfc673c28
|
@ -302,10 +302,16 @@ shutdown(duplicate_id, _State) ->
|
||||||
shutdown(_, #proto_state{clientid = undefined}) ->
|
shutdown(_, #proto_state{clientid = undefined}) ->
|
||||||
ignore;
|
ignore;
|
||||||
|
|
||||||
shutdown(normal, #proto_state{peername = Peername, clientid = ClientId}) ->
|
shutdown(normal, #proto_state{peername = Peername, clientid = ClientId, will_msg = WillMsg}) ->
|
||||||
lager:info([{client, ClientId}], "Client ~s@~s: normal shutdown",
|
lager:info([{client, ClientId}], "Client ~s@~s: normal shutdown",
|
||||||
[ClientId, emqttd_net:format(Peername)]),
|
[ClientId, emqttd_net:format(Peername)]),
|
||||||
try_unregister(ClientId),
|
try_unregister(ClientId),
|
||||||
|
if
|
||||||
|
WillMsg =/= undefined ->
|
||||||
|
send_willmsg(ClientId, WillMsg);
|
||||||
|
true ->
|
||||||
|
ok
|
||||||
|
end,
|
||||||
emqttd_broker:foreach_hooks(client_disconnected, [normal, ClientId]);
|
emqttd_broker:foreach_hooks(client_disconnected, [normal, ClientId]);
|
||||||
|
|
||||||
shutdown(Error, #proto_state{peername = Peername, clientid = ClientId, will_msg = WillMsg}) ->
|
shutdown(Error, #proto_state{peername = Peername, clientid = ClientId, will_msg = WillMsg}) ->
|
||||||
|
@ -331,6 +337,7 @@ send_willmsg(_ClientId, undefined) ->
|
||||||
ignore;
|
ignore;
|
||||||
%%TODO:should call session...
|
%%TODO:should call session...
|
||||||
send_willmsg(ClientId, WillMsg) ->
|
send_willmsg(ClientId, WillMsg) ->
|
||||||
|
lager:info("Client ~s send willmsg: ~p", [ClientId, WillMsg]),
|
||||||
emqttd_pubsub:publish(ClientId, WillMsg).
|
emqttd_pubsub:publish(ClientId, WillMsg).
|
||||||
|
|
||||||
start_keepalive(0) -> ignore;
|
start_keepalive(0) -> ignore;
|
||||||
|
|
Loading…
Reference in New Issue