MCPcopy
hub / github.com/aceld/zinx / newKcpClientConn

Function newKcpClientConn

znet/kcp_connection.go:161–185  ·  view source on GitHub ↗

newKcpServerConn :for Server, method to create a Client-side connection with Client-specific properties (创建一个Client服务端特性的连接的方法)

(client ziface.IClient, conn *kcp.UDPSession)

Source from the content-addressed store, hash-verified

159// newKcpServerConn :for Server, method to create a Client-side connection with Client-specific properties
160// (创建一个Client服务端特性的连接的方法)
161func newKcpClientConn(client ziface.IClient, conn *kcp.UDPSession) ziface.IConnection {
162 c := &KcpConnection{
163 conn: conn,
164 connID: 0, // client ignore
165 connIdStr: "", // client ignore
166 msgBuffChan: nil,
167 property: nil,
168 name: client.GetName(),
169 localAddr: conn.LocalAddr().String(),
170 remoteAddr: conn.RemoteAddr().String(),
171 }
172
173 lengthField := client.GetLengthField()
174 if lengthField != nil {
175 c.frameDecoder = zinterceptor.NewFrameDecoder(*lengthField)
176 }
177
178 // Inherited properties from server (从client继承过来的属性)
179 c.packet = client.GetPacket()
180 c.onConnStart = client.GetOnConnStart()
181 c.onConnStop = client.GetOnConnStop()
182 c.msgHandler = client.GetMsgHandler()
183
184 return c
185}
186
187// StartWriter is the goroutine that writes messages to the client
188// (写消息Goroutine, 用户将数据发送给客户端)

Callers

nothing calls this directly

Calls 10

NewFrameDecoderFunction · 0.92
GetNameMethod · 0.65
LocalAddrMethod · 0.65
RemoteAddrMethod · 0.65
GetLengthFieldMethod · 0.65
GetPacketMethod · 0.65
GetOnConnStartMethod · 0.65
GetOnConnStopMethod · 0.65
GetMsgHandlerMethod · 0.65
StringMethod · 0.45

Tested by

no test coverage detected