mirror of
https://github.com/Mrs4s/MiraiGo.git
synced 2025-05-04 19:17:38 +08:00
fix(client): typo
This commit is contained in:
parent
69b3e62e0e
commit
aebceb9dcf
@ -237,7 +237,7 @@ func NewClientMd5(uin int64, passwordMd5 [16]byte) *QQClient {
|
|||||||
if len(cli.servers) > 3 {
|
if len(cli.servers) > 3 {
|
||||||
cli.servers = cli.servers[0 : len(cli.servers)/2] // 保留ping值中位数以上的server
|
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)
|
cli.TCP.UnexpectedDisconnect(cli.unexpectedDisconnect)
|
||||||
rand.Read(cli.RandomKey)
|
rand.Read(cli.RandomKey)
|
||||||
go cli.netLoop()
|
go cli.netLoop()
|
||||||
@ -988,8 +988,8 @@ func (c *QQClient) Disconnect() {
|
|||||||
c.TCP.Close()
|
c.TCP.Close()
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *QQClient) planedDisconnect(_ *utils.TCPListener) {
|
func (c *QQClient) plannedDisconnect(_ *utils.TCPListener) {
|
||||||
c.Debug("planed disconnect.")
|
c.Debug("planned disconnect.")
|
||||||
c.stat.DisconnectTimes++
|
c.stat.DisconnectTimes++
|
||||||
c.Online = false
|
c.Online = false
|
||||||
}
|
}
|
||||||
|
@ -10,16 +10,16 @@ import (
|
|||||||
|
|
||||||
type TCPListener struct {
|
type TCPListener struct {
|
||||||
conn net.Conn
|
conn net.Conn
|
||||||
planedDisconnect func(*TCPListener)
|
plannedDisconnect func(*TCPListener)
|
||||||
unexpectedDisconnect func(*TCPListener, error)
|
unexpectedDisconnect func(*TCPListener, error)
|
||||||
}
|
}
|
||||||
|
|
||||||
var ErrConnectionClosed = errors.New("connection closed")
|
var ErrConnectionClosed = errors.New("connection closed")
|
||||||
|
|
||||||
// PlanedDisconnect 预料中的断开连接
|
// PlannedDisconnect 预料中的断开连接
|
||||||
// 如调用 Close() Connect()
|
// 如调用 Close() Connect()
|
||||||
func (t *TCPListener) PlanedDisconnect(f func(*TCPListener)) {
|
func (t *TCPListener) PlannedDisconnect(f func(*TCPListener)) {
|
||||||
t.planedDisconnect = f
|
t.plannedDisconnect = f
|
||||||
}
|
}
|
||||||
|
|
||||||
// UnexpectedDisconnect 未预料钟的断开连接
|
// UnexpectedDisconnect 未预料钟的断开连接
|
||||||
@ -82,7 +82,7 @@ func (t *TCPListener) Close() {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
t.close()
|
t.close()
|
||||||
t.invokePlanedDisconnect()
|
t.invokePlannedDisconnect()
|
||||||
}
|
}
|
||||||
|
|
||||||
func (t *TCPListener) close() {
|
func (t *TCPListener) close() {
|
||||||
@ -93,9 +93,9 @@ func (t *TCPListener) close() {
|
|||||||
t.conn = nil
|
t.conn = nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (t *TCPListener) invokePlanedDisconnect() {
|
func (t *TCPListener) invokePlannedDisconnect() {
|
||||||
if t.planedDisconnect != nil {
|
if t.plannedDisconnect != nil {
|
||||||
go t.planedDisconnect(t)
|
go t.plannedDisconnect(t)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user