Skip to content

Commit

Permalink
feat: 重连时保留上个session的数据
Browse files Browse the repository at this point in the history
  • Loading branch information
chenqinghe committed Oct 18, 2022
1 parent 12cb418 commit c3b37e7
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions client.go
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,11 @@ func (cli *Client) reconnect(sess *Session) {

for cli.needReconnect(sess) && policy.Retry() {
if s, err := cli.Dial(addr.Network(), addr.String()); err == nil {
s.data = sess.data
s.id = sess.id
s.user = sess.user
s.lastPackTs = sess.lastPackTs
s.requests = sess.requests
*sess = *s // replace old session
return
}
Expand Down

0 comments on commit c3b37e7

Please sign in to comment.