mirror of
https://github.com/duanhf2012/origin.git
synced 2026-05-17 06:17:29 +08:00
1.优化网络模块
2.新增kcp模块
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
package network
|
||||
|
||||
package network
|
||||
import (
|
||||
"github.com/duanhf2012/origin/v2/log"
|
||||
"net"
|
||||
@@ -16,7 +16,7 @@ type TCPClient struct {
|
||||
ReadDeadline time.Duration
|
||||
WriteDeadline time.Duration
|
||||
AutoReconnect bool
|
||||
NewAgent func(*TCPConn) Agent
|
||||
NewAgent func(conn *NetConn) Agent
|
||||
cons ConnSet
|
||||
wg sync.WaitGroup
|
||||
closeFlag bool
|
||||
@@ -82,7 +82,7 @@ func (client *TCPClient) init() {
|
||||
|
||||
client.cons = make(ConnSet)
|
||||
client.closeFlag = false
|
||||
client.MsgParser.init()
|
||||
client.MsgParser.Init()
|
||||
}
|
||||
|
||||
func (client *TCPClient) GetCloseFlag() bool{
|
||||
@@ -126,7 +126,7 @@ reconnect:
|
||||
client.cons[conn] = struct{}{}
|
||||
client.Unlock()
|
||||
|
||||
tcpConn := newTCPConn(conn, client.PendingWriteNum, &client.MsgParser,client.WriteDeadline)
|
||||
tcpConn := newNetConn(conn, client.PendingWriteNum, &client.MsgParser,client.WriteDeadline)
|
||||
agent := client.NewAgent(tcpConn)
|
||||
agent.Run()
|
||||
|
||||
|
||||
Reference in New Issue
Block a user