chore(emqx): fmt codes
This commit is contained in:
parent
a889b0b6a9
commit
97c05d3a72
|
@ -1141,24 +1141,31 @@ return_sub_unsub_ack(Packet, Channel) ->
|
||||||
{reply, Reply :: term(), channel()}
|
{reply, Reply :: term(), channel()}
|
||||||
| {shutdown, Reason :: term(), Reply :: term(), channel()}
|
| {shutdown, Reason :: term(), Reply :: term(), channel()}
|
||||||
| {shutdown, Reason :: term(), Reply :: term(), emqx_types:packet(), channel()}.
|
| {shutdown, Reason :: term(), Reply :: term(), emqx_types:packet(), channel()}.
|
||||||
handle_call(kick, Channel = #channel{
|
handle_call(
|
||||||
|
kick,
|
||||||
|
Channel = #channel{
|
||||||
conn_state = ConnState,
|
conn_state = ConnState,
|
||||||
will_msg = WillMsg,
|
will_msg = WillMsg,
|
||||||
conninfo = #{proto_ver := ProtoVer}
|
conninfo = #{proto_ver := ProtoVer}
|
||||||
}) ->
|
}
|
||||||
|
) ->
|
||||||
(WillMsg =/= undefined) andalso publish_will_msg(WillMsg),
|
(WillMsg =/= undefined) andalso publish_will_msg(WillMsg),
|
||||||
Channel1 = case ConnState of
|
Channel1 =
|
||||||
|
case ConnState of
|
||||||
connected -> ensure_disconnected(kicked, Channel);
|
connected -> ensure_disconnected(kicked, Channel);
|
||||||
_ -> Channel
|
_ -> Channel
|
||||||
end,
|
end,
|
||||||
case ProtoVer == ?MQTT_PROTO_V5 andalso ConnState == connected of
|
case ProtoVer == ?MQTT_PROTO_V5 andalso ConnState == connected of
|
||||||
true ->
|
true ->
|
||||||
shutdown(kicked, ok,
|
shutdown(
|
||||||
?DISCONNECT_PACKET(?RC_ADMINISTRATIVE_ACTION), Channel1);
|
kicked,
|
||||||
|
ok,
|
||||||
|
?DISCONNECT_PACKET(?RC_ADMINISTRATIVE_ACTION),
|
||||||
|
Channel1
|
||||||
|
);
|
||||||
_ ->
|
_ ->
|
||||||
shutdown(kicked, ok, Channel1)
|
shutdown(kicked, ok, Channel1)
|
||||||
end;
|
end;
|
||||||
|
|
||||||
handle_call(discard, Channel) ->
|
handle_call(discard, Channel) ->
|
||||||
disconnect_and_shutdown(discarded, ok, Channel);
|
disconnect_and_shutdown(discarded, ok, Channel);
|
||||||
%% Session Takeover
|
%% Session Takeover
|
||||||
|
@ -2071,8 +2078,11 @@ maybe_publish_will_msg(Channel = #channel{will_msg = WillMsg}) ->
|
||||||
end.
|
end.
|
||||||
|
|
||||||
will_delay_interval(WillMsg) ->
|
will_delay_interval(WillMsg) ->
|
||||||
maps:get('Will-Delay-Interval',
|
maps:get(
|
||||||
emqx_message:get_header(properties, WillMsg, #{}), 0).
|
'Will-Delay-Interval',
|
||||||
|
emqx_message:get_header(properties, WillMsg, #{}),
|
||||||
|
0
|
||||||
|
).
|
||||||
|
|
||||||
publish_will_msg(Msg) ->
|
publish_will_msg(Msg) ->
|
||||||
_ = emqx_broker:publish(Msg),
|
_ = emqx_broker:publish(Msg),
|
||||||
|
@ -2085,8 +2095,7 @@ disconnect_reason(?RC_SUCCESS) -> normal;
|
||||||
disconnect_reason(ReasonCode) -> emqx_reason_codes:name(ReasonCode).
|
disconnect_reason(ReasonCode) -> emqx_reason_codes:name(ReasonCode).
|
||||||
|
|
||||||
reason_code(takenover) -> ?RC_SESSION_TAKEN_OVER;
|
reason_code(takenover) -> ?RC_SESSION_TAKEN_OVER;
|
||||||
reason_code(discarded) -> ?RC_SESSION_TAKEN_OVER;
|
reason_code(discarded) -> ?RC_SESSION_TAKEN_OVER.
|
||||||
reason_code(_) -> ?RC_NORMAL_DISCONNECTION.
|
|
||||||
|
|
||||||
%%--------------------------------------------------------------------
|
%%--------------------------------------------------------------------
|
||||||
%% Helper functions
|
%% Helper functions
|
||||||
|
|
|
@ -910,9 +910,9 @@ t_handle_call_kick(_) ->
|
||||||
Channelv5 = channel(),
|
Channelv5 = channel(),
|
||||||
Channelv4 = v4(Channelv5),
|
Channelv4 = v4(Channelv5),
|
||||||
{shutdown, kicked, ok, _} = emqx_channel:handle_call(kick, Channelv4),
|
{shutdown, kicked, ok, _} = emqx_channel:handle_call(kick, Channelv4),
|
||||||
{shutdown, kicked, ok,
|
{shutdown, kicked, ok, ?DISCONNECT_PACKET(?RC_ADMINISTRATIVE_ACTION), _} = emqx_channel:handle_call(
|
||||||
?DISCONNECT_PACKET(?RC_ADMINISTRATIVE_ACTION),
|
kick, Channelv5
|
||||||
_} = emqx_channel:handle_call(kick, Channelv5),
|
),
|
||||||
|
|
||||||
DisconnectedChannelv5 = channel(#{conn_state => disconnected}),
|
DisconnectedChannelv5 = channel(#{conn_state => disconnected}),
|
||||||
DisconnectedChannelv4 = v4(DisconnectedChannelv5),
|
DisconnectedChannelv4 = v4(DisconnectedChannelv5),
|
||||||
|
@ -926,9 +926,9 @@ t_handle_kicked_publish_will_msg(_) ->
|
||||||
|
|
||||||
Msg = emqx_message:make(test, <<"will_topic">>, <<"will_payload">>),
|
Msg = emqx_message:make(test, <<"will_topic">>, <<"will_payload">>),
|
||||||
|
|
||||||
{shutdown, kicked, ok,
|
{shutdown, kicked, ok, ?DISCONNECT_PACKET(?RC_ADMINISTRATIVE_ACTION), _} = emqx_channel:handle_call(
|
||||||
?DISCONNECT_PACKET(?RC_ADMINISTRATIVE_ACTION),
|
kick, channel(#{will_msg => Msg})
|
||||||
_} = emqx_channel:handle_call(kick, channel(#{will_msg => Msg})),
|
),
|
||||||
receive
|
receive
|
||||||
{pub, Msg} -> ok
|
{pub, Msg} -> ok
|
||||||
after 200 -> exit(will_message_not_published)
|
after 200 -> exit(will_message_not_published)
|
||||||
|
|
Loading…
Reference in New Issue