MCPcopy Index your code
hub / github.com/aceld/zinx / newClientConn

Function newClientConn

znet/connection.go:167–193  ·  view source on GitHub ↗

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

(client ziface.IClient, conn net.Conn)

Source from the content-addressed store, hash-verified

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

Callers 1

RestartMethod · 0.85

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