fix(gw): save coap channel info
This commit is contained in:
parent
a9b443ae34
commit
3fd9061418
|
@ -460,8 +460,9 @@ process_connect(#channel{ctx = Ctx,
|
||||||
{ok, _Sess} ->
|
{ok, _Sess} ->
|
||||||
RandVal = rand:uniform(?TOKEN_MAXIMUM),
|
RandVal = rand:uniform(?TOKEN_MAXIMUM),
|
||||||
Token = erlang:list_to_binary(erlang:integer_to_list(RandVal)),
|
Token = erlang:list_to_binary(erlang:integer_to_list(RandVal)),
|
||||||
|
NResult = Result#{events => [{event, connected}]},
|
||||||
iter(Iter,
|
iter(Iter,
|
||||||
reply({ok, created}, Token, Msg, Result),
|
reply({ok, created}, Token, Msg, NResult),
|
||||||
Channel#channel{token = Token});
|
Channel#channel{token = Token});
|
||||||
{error, Reason} ->
|
{error, Reason} ->
|
||||||
?SLOG(error, #{ msg => "failed_open_session"
|
?SLOG(error, #{ msg => "failed_open_session"
|
||||||
|
@ -568,7 +569,8 @@ process_out(Outs, Result, Channel, _) ->
|
||||||
Reply ->
|
Reply ->
|
||||||
[Reply | Outs2]
|
[Reply | Outs2]
|
||||||
end,
|
end,
|
||||||
{ok, {outgoing, Outs3}, Channel}.
|
Events = maps:get(events, Result, []),
|
||||||
|
{ok, [{outgoing, Outs3}] ++ Events, Channel}.
|
||||||
|
|
||||||
%% leaf node
|
%% leaf node
|
||||||
process_nothing(_, _, Channel) ->
|
process_nothing(_, _, Channel) ->
|
||||||
|
@ -607,4 +609,6 @@ process_reply(Reply, Result, #channel{session = Session} = Channel, _) ->
|
||||||
Session2 = emqx_coap_session:set_reply(Reply, Session),
|
Session2 = emqx_coap_session:set_reply(Reply, Session),
|
||||||
Outs = maps:get(out, Result, []),
|
Outs = maps:get(out, Result, []),
|
||||||
Outs2 = lists:reverse(Outs),
|
Outs2 = lists:reverse(Outs),
|
||||||
{ok, {outgoing, [Reply | Outs2]}, Channel#channel{session = Session2}}.
|
Events = maps:get(events, Result, []),
|
||||||
|
{ok, [{outgoing, [Reply | Outs2]}] ++ Events,
|
||||||
|
Channel#channel{session = Session2}}.
|
||||||
|
|
Loading…
Reference in New Issue