|
|
@@ -298,8 +298,9 @@ func (c *Line) cleanClose() {
|
|
|
|
|
|
// 连接开始运行
|
|
|
func (c *Line) Start(conn conn.Connect, host *HostInfo) {
|
|
|
- c.updated = time.Now()
|
|
|
- c.lastRead = time.Now() // 避免默认为0时被清理
|
|
|
+ now := time.Now()
|
|
|
+ c.updated = now
|
|
|
+ c.lastRead = now // 避免默认为0时被清理
|
|
|
c.conn = conn
|
|
|
c.host = host
|
|
|
go c.readPump()
|
|
|
@@ -316,19 +317,21 @@ func NewConnect(
|
|
|
conn conn.Connect,
|
|
|
host *HostInfo,
|
|
|
) *Line {
|
|
|
+ now := time.Now()
|
|
|
cc := &Line{
|
|
|
cf: cf,
|
|
|
channel: channel,
|
|
|
hub: hub,
|
|
|
- pingID: uint16(time.Now().UnixNano()) % config.ID_MAX,
|
|
|
+ pingID: uint16(now.UnixNano()) % config.ID_MAX,
|
|
|
|
|
|
sendRequest: make(chan *RequestData, 32),
|
|
|
sendResponse: make(chan *ResponseData, 32),
|
|
|
pingRequest: make(chan *PingData, 5),
|
|
|
closeConnect: make(chan bool, 5),
|
|
|
|
|
|
- lastRead: time.Now(), // 避免默认为0时被清理
|
|
|
- started: time.Now(),
|
|
|
+ lastRead: now, // 避免默认为0时被清理
|
|
|
+ started: now,
|
|
|
+ updated: now,
|
|
|
}
|
|
|
cc.Start(conn, host)
|
|
|
return cc
|