Skip to content

Commit

Permalink
go logout
Browse files Browse the repository at this point in the history
  • Loading branch information
skiffer-git committed Nov 25, 2021
1 parent a4e565f commit a4093c3
Showing 1 changed file with 27 additions and 26 deletions.
53 changes: 27 additions & 26 deletions open_im_sdk/init_login.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,38 +47,39 @@ func (im *IMManager) getServerTime() int64 {
}

func (u *UserRelated) logout(cb Base) {
u.stateMutex.Lock()
defer u.stateMutex.Unlock()
go func() {
u.stateMutex.Lock()
defer u.stateMutex.Unlock()

u.LoginState = LogoutCmd
sdkLog("set LoginState ", u.LoginState)
u.LoginState = LogoutCmd
sdkLog("set LoginState ", u.LoginState)

err := u.closeConn()
if err != nil {
if cb != nil {
cb.OnError(ErrCodeInitLogin, err.Error())
err := u.closeConn()
if err != nil {
if cb != nil {
cb.OnError(ErrCodeInitLogin, err.Error())
}
return
}
return
}
sdkLog("closeConn ok")
sdkLog("closeConn ok")

err = u.closeDB()
if err != nil {
if cb != nil {
cb.OnError(ErrCodeInitLogin, err.Error())
err = u.closeDB()
if err != nil {
if cb != nil {
cb.OnError(ErrCodeInitLogin, err.Error())
}
return
}
return
}
sdkLog("close db ok")

u.LoginUid = ""
u.token = ""
time.Sleep(time.Duration(6) * time.Second)
if cb != nil {
cb.OnSuccess("")
}
sdkLog("close db ok")

sdkLog("logout return")
u.LoginUid = ""
u.token = ""
time.Sleep(time.Duration(6) * time.Second)
if cb != nil {
cb.OnSuccess("")
}
sdkLog("logout return")
}()
}

func (u *UserRelated) login(uid, tk string, cb Base) {
Expand Down

0 comments on commit a4093c3

Please sign in to comment.