newServerConn :for Server, method to create a Client-side connection with Client-specific properties (创建一个Client服务端特性的连接的方法)
(client ziface.IClient, conn net.Conn)
| 165 | // newServerConn :for Server, method to create a Client-side connection with Client-specific properties |
| 166 | // (创建一个Client服务端特性的连接的方法) |
| 167 | func 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, 用户将数据发送给客户端) |
no test coverage detected