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(),
|
present := boolean(),
|
||||||
pendings => list()}}
|
pendings => list()}}
|
||||||
| {error, Reason :: term()}).
|
| {error, Reason :: term()}).
|
||||||
open_session(true, Client = #{client_id := ClientId}, Options) ->
|
open_session(true, ClientInfo = #{client_id := ClientId}, ConnInfo) ->
|
||||||
CleanStart = fun(_) ->
|
CleanStart = fun(_) ->
|
||||||
ok = discard_session(ClientId),
|
ok = discard_session(ClientId),
|
||||||
Session = emqx_session:init(Client, Options),
|
Session = emqx_session:init(ClientInfo, ConnInfo),
|
||||||
{ok, #{session => Session, present => false}}
|
{ok, #{session => Session, present => false}}
|
||||||
end,
|
end,
|
||||||
emqx_cm_locker:trans(ClientId, CleanStart);
|
emqx_cm_locker:trans(ClientId, CleanStart);
|
||||||
|
|
||||||
open_session(false, Client = #{client_id := ClientId}, Options) ->
|
open_session(false, ClientInfo = #{client_id := ClientId}, ConnInfo) ->
|
||||||
ResumeStart = fun(_) ->
|
ResumeStart = fun(_) ->
|
||||||
case takeover_session(ClientId) of
|
case takeover_session(ClientId) of
|
||||||
{ok, ConnMod, ChanPid, Session} ->
|
{ok, ConnMod, ChanPid, Session} ->
|
||||||
|
@ -179,7 +179,7 @@ open_session(false, Client = #{client_id := ClientId}, Options) ->
|
||||||
present => true,
|
present => true,
|
||||||
pendings => Pendings}};
|
pendings => Pendings}};
|
||||||
{error, not_found} ->
|
{error, not_found} ->
|
||||||
Session = emqx_session:init(Client, Options),
|
Session = emqx_session:init(ClientInfo, ConnInfo),
|
||||||
{ok, #{session => Session, present => false}}
|
{ok, #{session => Session, present => false}}
|
||||||
end
|
end
|
||||||
end,
|
end,
|
||||||
|
|
Loading…
Reference in New Issue