Skip to content

Commit

Permalink
fix(client): typo
Browse files Browse the repository at this point in the history
  • Loading branch information
StarHeartHunt committed Apr 25, 2021
1 parent 69b3e62 commit aebceb9
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 11 deletions.
6 changes: 3 additions & 3 deletions client/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -237,7 +237,7 @@ func NewClientMd5(uin int64, passwordMd5 [16]byte) *QQClient {
if len(cli.servers) > 3 {
cli.servers = cli.servers[0 : len(cli.servers)/2] // 保留ping值中位数以上的server
}
cli.TCP.PlanedDisconnect(cli.planedDisconnect)
cli.TCP.PlannedDisconnect(cli.plannedDisconnect)
cli.TCP.UnexpectedDisconnect(cli.unexpectedDisconnect)
rand.Read(cli.RandomKey)
go cli.netLoop()
Expand Down Expand Up @@ -988,8 +988,8 @@ func (c *QQClient) Disconnect() {
c.TCP.Close()
}

func (c *QQClient) planedDisconnect(_ *utils.TCPListener) {
c.Debug("planed disconnect.")
func (c *QQClient) plannedDisconnect(_ *utils.TCPListener) {
c.Debug("planned disconnect.")
c.stat.DisconnectTimes++
c.Online = false
}
Expand Down
16 changes: 8 additions & 8 deletions utils/connection.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,16 +10,16 @@ import (

type TCPListener struct {
conn net.Conn
planedDisconnect func(*TCPListener)
plannedDisconnect func(*TCPListener)
unexpectedDisconnect func(*TCPListener, error)
}

var ErrConnectionClosed = errors.New("connection closed")

// PlanedDisconnect 预料中的断开连接
// PlannedDisconnect 预料中的断开连接
// 如调用 Close() Connect()
func (t *TCPListener) PlanedDisconnect(f func(*TCPListener)) {
t.planedDisconnect = f
func (t *TCPListener) PlannedDisconnect(f func(*TCPListener)) {
t.plannedDisconnect = f
}

// UnexpectedDisconnect 未预料钟的断开连接
Expand Down Expand Up @@ -82,7 +82,7 @@ func (t *TCPListener) Close() {
return
}
t.close()
t.invokePlanedDisconnect()
t.invokePlannedDisconnect()
}

func (t *TCPListener) close() {
Expand All @@ -93,9 +93,9 @@ func (t *TCPListener) close() {
t.conn = nil
}

func (t *TCPListener) invokePlanedDisconnect() {
if t.planedDisconnect != nil {
go t.planedDisconnect(t)
func (t *TCPListener) invokePlannedDisconnect() {
if t.plannedDisconnect != nil {
go t.plannedDisconnect(t)
}
}

Expand Down

0 comments on commit aebceb9

Please sign in to comment.