Fix bug in issue#1848

This commit is contained in:
周子博 2018-09-22 18:19:57 +08:00 committed by Feng Lee
parent 5afaac4641
commit 4336b7c9a0
1 changed files with 17 additions and 9 deletions

View File

@ -489,22 +489,30 @@ deliver({connack, ?RC_SUCCESS, SP}, PState = #pstate{zone = Zone,
max_topic_alias := MaxAlias, max_topic_alias := MaxAlias,
mqtt_shared_subscription := Shared, mqtt_shared_subscription := Shared,
mqtt_wildcard_subscription := Wildcard} = caps(PState), mqtt_wildcard_subscription := Wildcard} = caps(PState),
Props = #{'Maximum-QoS' => MaxQoS, Props = #{'Retain-Available' => flag(Retain),
'Retain-Available' => flag(Retain),
'Maximum-Packet-Size' => MaxPktSize, 'Maximum-Packet-Size' => MaxPktSize,
'Topic-Alias-Maximum' => MaxAlias, 'Topic-Alias-Maximum' => MaxAlias,
'Wildcard-Subscription-Available' => flag(Wildcard), 'Wildcard-Subscription-Available' => flag(Wildcard),
'Subscription-Identifier-Available' => 1, 'Subscription-Identifier-Available' => 1,
'Shared-Subscription-Available' => flag(Shared)}, 'Shared-Subscription-Available' => flag(Shared)},
Props1 = if IsAssigned ->
Props#{'Assigned-Client-Identifier' => ClientId}; Props1 = if
true -> Props MaxQoS =:= ?QOS_2 ->
Props;
true ->
maps:put('Maximum-QoS', MaxQoS, Props)
end,
Props2 = if IsAssigned ->
Props1#{'Assigned-Client-Identifier' => ClientId};
true -> Props1
end, end,
Props2 = case emqx_zone:get_env(Zone, server_keepalive) of
undefined -> Props1; Props3 = case emqx_zone:get_env(Zone, server_keepalive) of
Keepalive -> Props1#{'Server-Keep-Alive' => Keepalive} undefined -> Props2;
Keepalive -> Props2#{'Server-Keep-Alive' => Keepalive}
end, end,
send(?CONNACK_PACKET(?RC_SUCCESS, SP, Props2), PState); send(?CONNACK_PACKET(?RC_SUCCESS, SP, Props3), PState);
deliver({connack, ReasonCode, SP}, PState) -> deliver({connack, ReasonCode, SP}, PState) ->
send(?CONNACK_PACKET(ReasonCode, SP), PState); send(?CONNACK_PACKET(ReasonCode, SP), PState);