func (cfg Config) validate(log log.Logger, pn player.Name, conn Conn) (net.Addr, error) {
	switch {
	case len(pn) == 0:
		return nil, fmt.Errorf("player name required")
	case conn == nil:
		return nil, fmt.Errorf("websocket connection required")
	}
	a := conn.RemoteAddr()
	switch {
	case a == nil:
		return nil, fmt.Errorf("remote address of connection required")
	case log == nil:
		return nil, fmt.Errorf("log required")
	case cfg.TimeFunc == nil:
		return nil, fmt.Errorf("time func required")
	case cfg.ReadWait <= 0:
		return nil, fmt.Errorf("positive read wait period required")
	case cfg.WriteWait <= 0:
		return nil, fmt.Errorf("positive write wait period required")
	case cfg.PingPeriod <= 0:
		return nil, fmt.Errorf("positive ping period required")
	case cfg.HTTPPingPeriod <= 0:
		return nil, fmt.Errorf("positive http ping period required")
	case cfg.PingPeriod <= cfg.WriteWait:
		return nil, fmt.Errorf("ping period should be greater than write wait")
	}
	return a, nil
}
// validate ensures the configuration has no errors.
validate ensures the configuration has no errors.
// validate ensures the configuration has no errors .
func (cfg Config) validate(log log.Logger, pn player.Name, conn Conn) (net.Addr, error) {
	switch {
	case len(pn) == 0:
		return nil, fmt.Errorf("player name required")
	case conn == nil:
		return nil, fmt.Errorf("websocket connection required")
	}
	a := conn.RemoteAddr()
	switch {
	case a == nil:
		return nil, fmt.Errorf("remote address of connection required")
	case log == nil:
		return nil, fmt.Errorf("log required")
	case cfg.TimeFunc == nil:
		return nil, fmt.Errorf("time func required")
	case cfg.ReadWait <= 0:
		return nil, fmt.Errorf("positive read wait period required")
	case cfg.WriteWait <= 0:
		return nil, fmt.Errorf("positive write wait period required")
	case cfg.PingPeriod <= 0:
		return nil, fmt.Errorf("positive ping period required")
	case cfg.HTTPPingPeriod <= 0:
		return nil, fmt.Errorf("positive http ping period required")
	case cfg.PingPeriod <= cfg.WriteWait:
		return nil, fmt.Errorf("ping period should be greater than write wait")
	}
	return a, nil
}
func ( cfg Config ) validate ( log log . Logger , pn player . Name , conn Conn ) ( net . Addr , error ) { switch { case len ( pn ) == 0 : return nil , fmt . Errorf ( " " ) case conn == nil : return nil , fmt . Errorf ( " " ) } a := conn . RemoteAddr ( ) switch { case a == nil : return nil , fmt . Errorf ( " " ) case log == nil : return nil , fmt . Errorf ( " " ) case cfg . TimeFunc == nil : return nil , fmt . Errorf ( " " ) case cfg . ReadWait <= 0 : return nil , fmt . Errorf ( " " ) case cfg . WriteWait <= 0 : return nil , fmt . Errorf ( " " ) case cfg . PingPeriod <= 0 : return nil , fmt . Errorf ( " " ) case cfg . HTTPPingPeriod <= 0 : return nil , fmt . Errorf ( " " ) case cfg . PingPeriod <= cfg . WriteWait : return nil , fmt . Errorf ( " " ) } return a , nil }
validate ensures the configuration has no errors.
validate ensures the configuration has no errors .