mirror of
https://github.com/duanhf2012/origin.git
synced 2026-03-06 22:27:36 +08:00
优化tcpservice
This commit is contained in:
@@ -41,7 +41,7 @@ type TcpPack struct {
|
|||||||
|
|
||||||
type Client struct {
|
type Client struct {
|
||||||
id string
|
id string
|
||||||
tcpConn *network.TCPConn
|
tcpConn *network.NetConn
|
||||||
tcpService *TcpService
|
tcpService *TcpService
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -120,13 +120,13 @@ func (tcpService *TcpService) SetProcessor(process processor.IProcessor, handler
|
|||||||
tcpService.RegEventReceiverFunc(event.Sys_Event_Tcp, handler, tcpService.TcpEventHandler)
|
tcpService.RegEventReceiverFunc(event.Sys_Event_Tcp, handler, tcpService.TcpEventHandler)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (tcpService *TcpService) NewClient(conn *network.TCPConn) network.Agent {
|
func (tcpService *TcpService) NewClient(conn network.Conn) network.Agent {
|
||||||
tcpService.mapClientLocker.Lock()
|
tcpService.mapClientLocker.Lock()
|
||||||
defer tcpService.mapClientLocker.Unlock()
|
defer tcpService.mapClientLocker.Unlock()
|
||||||
|
|
||||||
uuId, _ := uuid.NewUUID()
|
uuId, _ := uuid.NewUUID()
|
||||||
clientId := strings.ReplaceAll(uuId.String(), "-", "")
|
clientId := strings.ReplaceAll(uuId.String(), "-", "")
|
||||||
pClient := &Client{tcpConn: conn, id: clientId}
|
pClient := &Client{tcpConn: conn.(*network.NetConn), id: clientId}
|
||||||
pClient.tcpService = tcpService
|
pClient.tcpService = tcpService
|
||||||
tcpService.mapClient[clientId] = pClient
|
tcpService.mapClient[clientId] = pClient
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user