mirror of
https://github.com/Mrs4s/MiraiGo.git
synced 2025-05-04 11:07:40 +08:00
Merge pull request #148 from StarHeartHunt/master
This commit is contained in:
commit
40ae0b4eca
@ -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
|
||||
}
|
||||
|
@ -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)
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user