Return the '{enter, connected}' event first
This commit is contained in:
parent
6233aa7d46
commit
a1877f3f42
|
@ -572,15 +572,13 @@ handle_out({connack, ?RC_SUCCESS, SP, ConnPkt},
|
||||||
AckPacket = ?CONNACK_PACKET(?RC_SUCCESS, SP, AckProps),
|
AckPacket = ?CONNACK_PACKET(?RC_SUCCESS, SP, AckProps),
|
||||||
case maybe_resume_session(Channel2) of
|
case maybe_resume_session(Channel2) of
|
||||||
ignore ->
|
ignore ->
|
||||||
Output = [{outgoing, AckPacket}, {enter, connected}],
|
{ok, [{enter, connected}, {outgoing, AckPacket}], Channel2};
|
||||||
{ok, Output, Channel2};
|
|
||||||
{ok, Publishes, NSession} ->
|
{ok, Publishes, NSession} ->
|
||||||
Channel3 = Channel2#channel{session = NSession,
|
Channel3 = Channel2#channel{session = NSession,
|
||||||
resuming = false,
|
resuming = false,
|
||||||
pendings = []},
|
pendings = []},
|
||||||
{ok, {outgoing, Packets}, _} = handle_out({publish, Publishes}, Channel3),
|
{ok, {outgoing, Packets}, _} = handle_out({publish, Publishes}, Channel3),
|
||||||
Output = [{outgoing, [AckPacket|Packets]}, {enter, connected}],
|
{ok, [{enter, connected}, {outgoing, [AckPacket|Packets]}], Channel3}
|
||||||
{ok, Output, Channel3}
|
|
||||||
end;
|
end;
|
||||||
|
|
||||||
handle_out({connack, ReasonCode, _ConnPkt}, Channel = #channel{conninfo = ConnInfo,
|
handle_out({connack, ReasonCode, _ConnPkt}, Channel = #channel{conninfo = ConnInfo,
|
||||||
|
|
|
@ -72,7 +72,7 @@ t_handle_connect(_) ->
|
||||||
with_channel(
|
with_channel(
|
||||||
fun(Channel) ->
|
fun(Channel) ->
|
||||||
ConnAck = ?CONNACK_PACKET(?RC_SUCCESS, 0, #{}),
|
ConnAck = ?CONNACK_PACKET(?RC_SUCCESS, 0, #{}),
|
||||||
ExpectedOutput = [{outgoing, ConnAck},{enter, connected}],
|
ExpectedOutput = [{enter, connected},{outgoing, ConnAck}],
|
||||||
{ok, Output, Channel1} = handle_in(?CONNECT_PACKET(ConnPkt), Channel),
|
{ok, Output, Channel1} = handle_in(?CONNECT_PACKET(ConnPkt), Channel),
|
||||||
?assertEqual(ExpectedOutput, Output),
|
?assertEqual(ExpectedOutput, Output),
|
||||||
#{clientid := ClientId, username := Username} = emqx_channel:info(clientinfo, Channel1),
|
#{clientid := ClientId, username := Username} = emqx_channel:info(clientinfo, Channel1),
|
||||||
|
@ -207,7 +207,7 @@ t_handle_out_connack(_) ->
|
||||||
},
|
},
|
||||||
with_channel(
|
with_channel(
|
||||||
fun(Channel) ->
|
fun(Channel) ->
|
||||||
{ok, [{outgoing, ?CONNACK_PACKET(?RC_SUCCESS, SP, _)}, {enter, connected}], _Chan}
|
{ok, [{enter, connected},{outgoing, ?CONNACK_PACKET(?RC_SUCCESS, SP, _)}], _Chan}
|
||||||
= handle_out({connack, ?RC_SUCCESS, 0, ConnPkt}, Channel),
|
= handle_out({connack, ?RC_SUCCESS, 0, ConnPkt}, Channel),
|
||||||
{stop, {shutdown, not_authorized}, ?CONNACK_PACKET(?RC_NOT_AUTHORIZED), _}
|
{stop, {shutdown, not_authorized}, ?CONNACK_PACKET(?RC_NOT_AUTHORIZED), _}
|
||||||
= handle_out({connack, ?RC_NOT_AUTHORIZED, ConnPkt}, Channel)
|
= handle_out({connack, ?RC_NOT_AUTHORIZED, ConnPkt}, Channel)
|
||||||
|
|
Loading…
Reference in New Issue