Skip to content

Commit

Permalink
fix: token cb update. (#565)
Browse files Browse the repository at this point in the history
Signed-off-by: Gordon <[email protected]>
  • Loading branch information
FGadvancer authored Jul 3, 2024
1 parent c894656 commit d34871c
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 5 deletions.
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ require golang.org/x/net v0.22.0
require (
github.com/google/go-cmp v0.6.0
github.com/openimsdk/protocol v0.0.69-alpha.16
github.com/openimsdk/tools v0.0.49-alpha.12
github.com/openimsdk/tools v0.0.49-alpha.40
github.com/patrickmn/go-cache v2.1.0+incompatible
go.etcd.io/etcd/api/v3 v3.5.13
golang.org/x/image v0.15.0
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,8 @@ github.com/mattn/go-sqlite3 v1.14.22 h1:2gZY6PC6kBnID23Tichd1K+Z0oS6nE/XwU+Vz/5o
github.com/mattn/go-sqlite3 v1.14.22/go.mod h1:Uh1q+B4BYcTPb+yiD3kU8Ct7aC0hY9fxUwlHK0RXw+Y=
github.com/openimsdk/protocol v0.0.69-alpha.16 h1:ciSqm2rjBdpScpkQm3wPjAFv0YbIRp8MITRkDZWVv6c=
github.com/openimsdk/protocol v0.0.69-alpha.16/go.mod h1:OZQA9FR55lseYoN2Ql1XAHYKHJGu7OMNkUbuekrKCM8=
github.com/openimsdk/tools v0.0.49-alpha.12 h1:vsr63W1kHW1dEw9yelMhmr72WmsrjKfs2vXww3upfWI=
github.com/openimsdk/tools v0.0.49-alpha.12/go.mod h1:g7mkHXYUPi0/8aAX8VPMHpnb3hqdV69Jph+bXOGvvNM=
github.com/openimsdk/tools v0.0.49-alpha.40 h1:f7BVjJo30MC64diHiaRSmbJ6Uu0/CpZrohctkd3T4f0=
github.com/openimsdk/tools v0.0.49-alpha.40/go.mod h1:zc0maZ2ohXlHd0ylY5JnCE8uqq/hslhcfcKa6iO5PCU=
github.com/patrickmn/go-cache v2.1.0+incompatible h1:HRMgzkcYKYpi3C8ajMPV8OFXaaRUnok+kx1WdO15EQc=
github.com/patrickmn/go-cache v2.1.0+incompatible/go.mod h1:3Qf8kWWT7OJRJbdiICTKqZju1ZixQ/KpMGzzAfe6+WQ=
github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4=
Expand Down
5 changes: 4 additions & 1 deletion internal/interaction/long_conn_mgr.go
Original file line number Diff line number Diff line change
Expand Up @@ -527,9 +527,12 @@ func (c *LongConnMgr) reConn(ctx context.Context, num *int) (needRecon bool, err
switch apiResp.ErrCode {
case
errs.TokenExpiredError,
errs.TokenInvalidError,
errs.TokenMalformedError,
errs.TokenNotValidYetError,
errs.TokenUnknownError:
errs.TokenUnknownError,
errs.TokenNotExistError,
errs.TokenKickedError:
return false, err
default:
return true, err
Expand Down
6 changes: 5 additions & 1 deletion open_im_sdk/apicb.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,14 +36,18 @@ func (c *apiErrCallback) OnError(ctx context.Context, err error) {
_ = common.TriggerCmdLogOut(ctx, c.loginMgrCh)
}
case
errs.TokenInvalidError,
errs.TokenMalformedError,
errs.TokenNotValidYetError,
errs.TokenUnknownError:
errs.TokenUnknownError,
errs.TokenNotExistError:
if atomic.CompareAndSwapInt32(&c.tokenInvalidState, 0, 1) {
log.ZError(ctx, "OnUserTokenInvalid callback", err)
c.listener.OnUserTokenInvalid(err.Error())
_ = common.TriggerCmdLogOut(ctx, c.loginMgrCh)
}

case errs.TokenKickedError:
if atomic.CompareAndSwapInt32(&c.kickedOfflineState, 0, 1) {
log.ZError(ctx, "OnKickedOffline callback", err)
c.listener.OnKickedOffline()
Expand Down

0 comments on commit d34871c

Please sign in to comment.