1.优化网络模块

2.新增kcp模块
This commit is contained in:
duanhf2012
2024-09-30 14:31:24 +08:00
parent 39116c4402
commit b943ea9a83
20 changed files with 656 additions and 214 deletions

View File

@@ -29,7 +29,7 @@ type IWriter interface {
}
type IRealClient interface {
SetConn(conn *network.TCPConn)
SetConn(conn *network.NetConn)
Close(waitDone bool)
AsyncCall(NodeId string, timeout time.Duration, rpcHandler IRpcHandler, serviceMethod string, callback reflect.Value, args interface{}, replyParam interface{}, cancelable bool) (CancelRpc, error)
@@ -52,7 +52,7 @@ type Client struct {
IRealClient
}
func (client *Client) NewClientAgent(conn *network.TCPConn) network.Agent {
func (client *Client) NewClientAgent(conn *network.NetConn) network.Agent {
client.SetConn(conn)
return client

View File

@@ -31,7 +31,7 @@ func (lc *LClient) IsConnected() bool {
return true
}
func (lc *LClient) SetConn(conn *network.TCPConn) {
func (lc *LClient) SetConn(conn *network.NetConn) {
}
func (lc *LClient) Close(waitDone bool) {

View File

@@ -29,7 +29,7 @@ func (nc *NatsClient) onSubscribe(msg *nats.Msg) {
nc.client.processRpcResponse(msg.Data)
}
func (nc *NatsClient) SetConn(conn *network.TCPConn) {
func (nc *NatsClient) SetConn(conn *network.NetConn) {
}
func (nc *NatsClient) Close(waitDone bool) {

View File

@@ -15,7 +15,7 @@ import (
type RClient struct {
selfClient *Client
network.TCPClient
conn *network.TCPConn
conn *network.NetConn
notifyEventFun NotifyEventFun
}
@@ -27,7 +27,7 @@ func (rc *RClient) IsConnected() bool {
return rc.conn != nil && rc.conn.IsConnected() == true
}
func (rc *RClient) GetConn() *network.TCPConn {
func (rc *RClient) GetConn() *network.NetConn {
rc.Lock()
conn := rc.conn
rc.Unlock()
@@ -35,7 +35,7 @@ func (rc *RClient) GetConn() *network.TCPConn {
return conn
}
func (rc *RClient) SetConn(conn *network.TCPConn) {
func (rc *RClient) SetConn(conn *network.NetConn) {
rc.Lock()
rc.conn = conn
rc.Unlock()

View File

@@ -211,7 +211,7 @@ func (agent *RpcAgent) Destroy() {
agent.conn.Destroy()
}
func (server *Server) NewAgent(c *network.TCPConn) network.Agent {
func (server *Server) NewAgent(c network.Conn) network.Agent {
agent := &RpcAgent{conn: c, rpcServer: server}
return agent