diff --git a/client/client.go b/client/client.go index 5d73fbcf..a620105f 100644 --- a/client/client.go +++ b/client/client.go @@ -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() @@ -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 } diff --git a/utils/connection.go b/utils/connection.go index d7ff76f9..af9cf54f 100644 --- a/utils/connection.go +++ b/utils/connection.go @@ -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 未预料钟的断开连接 @@ -82,7 +82,7 @@ func (t *TCPListener) Close() { return } t.close() - t.invokePlanedDisconnect() + t.invokePlannedDisconnect() } func (t *TCPListener) close() { @@ -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) } }