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

Function newWsClientConn

znet/ws_connection.go:156–181  ·  view source on GitHub ↗

newClientConn :for Client, creates a connection with Client-side features (newClientConn :for Client, 创建一个Client服务端特性的连接的方法)

(client ziface.IClient, conn *websocket.Conn)

Source from the content-addressed store, hash-verified

154// newClientConn :for Client, creates a connection with Client-side features
155// (newClientConn :for Client, 创建一个Client服务端特性的连接的方法)
156func newWsClientConn(client ziface.IClient, conn *websocket.Conn) ziface.IConnection {
157 c := &WsConnection{
158 conn: conn,
159 connID: 0, // client ignore
160 connIdStr: "", // client ignore
161 isClosed: false,
162 msgBuffChan: nil,
163 property: nil,
164 name: client.GetName(),
165 localAddr: conn.LocalAddr().String(),
166 remoteAddr: conn.RemoteAddr().String(),
167 }
168
169 lengthField := client.GetLengthField()
170 if lengthField != nil {
171 c.frameDecoder = zinterceptor.NewFrameDecoder(*lengthField)
172 }
173
174 // Inherit properties from client (从client继承过来的属性)
175 c.packet = client.GetPacket()
176 c.onConnStart = client.GetOnConnStart()
177 c.onConnStop = client.GetOnConnStop()
178 c.msgHandler = client.GetMsgHandler()
179
180 return c
181}
182
183// StartWriter is a Goroutine that sends messages to the client
184// (StartWriter 写消息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