newServerConn :for Server, method to create a Server-side connection with Server-specific properties (创建一个Server服务端特性的连接的方法)
(server ziface.IServer, conn net.Conn, connID uint64)
| 125 | // newServerConn :for Server, method to create a Server-side connection with Server-specific properties |
| 126 | // (创建一个Server服务端特性的连接的方法) |
| 127 | func newServerConn(server ziface.IServer, conn net.Conn, connID uint64) ziface.IConnection { |
| 128 | |
| 129 | // Initialize Conn properties |
| 130 | c := &Connection{ |
| 131 | conn: conn, |
| 132 | bufWriter: bufio.NewWriterSize(conn, 16*1024), |
| 133 | connID: connID, |
| 134 | connIdStr: strconv.FormatUint(connID, 10), |
| 135 | startWriterFlag: 0, |
| 136 | msgBuffChan: nil, |
| 137 | property: nil, |
| 138 | name: server.ServerName(), |
| 139 | localAddr: conn.LocalAddr().String(), |
| 140 | remoteAddr: conn.RemoteAddr().String(), |
| 141 | } |
| 142 | |
| 143 | lengthField := server.GetLengthField() |
| 144 | if lengthField != nil { |
| 145 | c.frameDecoder = zinterceptor.NewFrameDecoder(*lengthField) |
| 146 | } |
| 147 | |
| 148 | // Inherited properties from server (从server继承过来的属性) |
| 149 | c.packet = server.GetPacket() |
| 150 | c.onConnStart = server.GetOnConnStart() |
| 151 | c.onConnStop = server.GetOnConnStop() |
| 152 | c.msgHandler = server.GetMsgHandler() |
| 153 | |
| 154 | // Bind the current Connection with the Server's ConnManager |
| 155 | // (将当前的Connection与Server的ConnManager绑定) |
| 156 | c.connManager = server.GetConnMgr() |
| 157 | |
| 158 | // Add the newly created Conn to the connection manager |
| 159 | // (将新创建的Conn添加到连接管理中) |
| 160 | server.GetConnMgr().Add(c) |
| 161 | |
| 162 | return c |
| 163 | } |
| 164 | |
| 165 | // newServerConn :for Server, method to create a Client-side connection with Client-specific properties |
| 166 | // (创建一个Client服务端特性的连接的方法) |
no test coverage detected