newClientConn :for Client, creates a connection with Client-side features (newClientConn :for Client, 创建一个Client服务端特性的连接的方法)
(client ziface.IClient, conn *websocket.Conn)
| 154 | // newClientConn :for Client, creates a connection with Client-side features |
| 155 | // (newClientConn :for Client, 创建一个Client服务端特性的连接的方法) |
| 156 | func 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, 用户将数据发送给客户端) |
no test coverage detected