Exemple #1
0
func NewClient(manager *Manager, conn *net.TCPConn) *Client {
	ip := strings.Split(conn.RemoteAddr().String(), ":")
	return &Client{
		manager: manager,
		host:    ip[0],
		uhost:   utils.Ip2Uint32(ip[0]),
		port:    ip[1],
		conn:    conn,
	}
}
Exemple #2
0
func NewServer(manager *Manager, conn *net.TCPConn) *Server {
	ip := strings.Split(conn.RemoteAddr().String(), ":")
	port, _ := strconv.ParseUint(ip[1], 10, 64)

	return &Server{
		manager:   manager,
		host:      ip[0],
		uhost:     utils.Ip2Uint32(ip[0]),
		port:      uint32(port),
		conn:      conn,
		lastHeart: time.Now().Unix(),
		stat:      nil,
	}
}