Improve the 'open_session/3' API
This commit is contained in:
parent
94c324d7a3
commit
a313d1c722
|
@ -161,15 +161,15 @@ set_chan_stats(ClientId, ChanPid, Stats) ->
|
|||
present := boolean(),
|
||||
pendings => list()}}
|
||||
| {error, Reason :: term()}).
|
||||
open_session(true, Client = #{client_id := ClientId}, Options) ->
|
||||
open_session(true, ClientInfo = #{client_id := ClientId}, ConnInfo) ->
|
||||
CleanStart = fun(_) ->
|
||||
ok = discard_session(ClientId),
|
||||
Session = emqx_session:init(Client, Options),
|
||||
Session = emqx_session:init(ClientInfo, ConnInfo),
|
||||
{ok, #{session => Session, present => false}}
|
||||
end,
|
||||
emqx_cm_locker:trans(ClientId, CleanStart);
|
||||
|
||||
open_session(false, Client = #{client_id := ClientId}, Options) ->
|
||||
open_session(false, ClientInfo = #{client_id := ClientId}, ConnInfo) ->
|
||||
ResumeStart = fun(_) ->
|
||||
case takeover_session(ClientId) of
|
||||
{ok, ConnMod, ChanPid, Session} ->
|
||||
|
@ -179,7 +179,7 @@ open_session(false, Client = #{client_id := ClientId}, Options) ->
|
|||
present => true,
|
||||
pendings => Pendings}};
|
||||
{error, not_found} ->
|
||||
Session = emqx_session:init(Client, Options),
|
||||
Session = emqx_session:init(ClientInfo, ConnInfo),
|
||||
{ok, #{session => Session, present => false}}
|
||||
end
|
||||
end,
|
||||
|
|
Loading…
Reference in New Issue