func (f Flags) CreateServer(ctx context.Context, log log.Logger, db *db.Database, e EmbeddedData) (*server.Server, error) {
	timeFunc := func() int64 {
		return time.Now().Unix()
	}
	key := make([]byte, 64)
	if _, err := crypto_rand.Reader.Read(key); err != nil {
		return nil, fmt.Errorf("generating Tokenizer key: %w", err)
	}
	tokenizerCfg := f.tokenizerConfig(timeFunc)
	tokenizer, err := tokenizerCfg.NewTokenizer(key)
	if err != nil {
		return nil, fmt.Errorf("creating authentication tokenizer: %w", err)
	}
	userDao, err := user.NewDao(db)
	if err != nil {
		return nil, fmt.Errorf("creating user dao: %w", err)
	}
	socketRunnerCfg := f.socketRunnerConfig(timeFunc)
	socketRunner, err := socketRunnerCfg.NewRunner(log)
	if err != nil {
		return nil, fmt.Errorf("creating socket runner: %w", err)
	}
	wordsReader := bytes.NewReader(e.Words)
	wordValidator, err := word.NewValidator(wordsReader)
	if err != nil {
		return nil, fmt.Errorf("creating word validator: %v", err)
	}
	gameRunnerCfg := f.gameRunnerConfig(timeFunc)
	gameRunner, err := gameRunnerCfg.NewRunner(log, wordValidator, userDao)
	if err != nil {
		return nil, fmt.Errorf("creating game runner: %w", err)
	}
	lobbyCfg := f.lobbyConfig()
	lobby, err := lobbyCfg.NewLobby(log, socketRunner, gameRunner)
	if err != nil {
		return nil, fmt.Errorf("creating lobby: %w", err)
	}
	challenge := server.Challenge{
		Token: f.ChallengeToken,
		Key:   f.ChallengeKey,
	}
	colorCfg := f.colorConfig()
	cfg := server.Config{
		HTTPPort:      f.HTTPPort,
		HTTPSPort:     f.HTTPSPort,
		StopDur:       20 * time.Second, // should be longer than the PingPeriod of sockets so they can close gracefully
		CacheSec:      f.CacheSec,
		Version:       strings.TrimSpace(string(e.Version)),
		TLSCertPEM:    string(e.TLSCertPEM),
		TLSKeyPEM:     string(e.TLSKeyPEM),
		Challenge:     challenge,
		ColorConfig:   colorCfg,
		NoTLSRedirect: f.NoTLSRedirect,
	}
	p := server.Parameters{
		Logger:     log,
		Tokenizer:  tokenizer,
		UserDao:    userDao,
		Lobby:      lobby,
		StaticFS:   e.StaticFS,
		TemplateFS: e.TemplateFS,
	}
	return cfg.NewServer(p)
}
// CreateServer creates the server.
CreateServer creates the server.
// CreateServer creates the server .
func (f Flags) CreateServer(ctx context.Context, log log.Logger, db *db.Database, e EmbeddedData) (*server.Server, error) {
	timeFunc := func() int64 {
		return time.Now().Unix()
	}
	key := make([]byte, 64)
	if _, err := crypto_rand.Reader.Read(key); err != nil {
		return nil, fmt.Errorf("generating Tokenizer key: %w", err)
	}
	tokenizerCfg := f.tokenizerConfig(timeFunc)
	tokenizer, err := tokenizerCfg.NewTokenizer(key)
	if err != nil {
		return nil, fmt.Errorf("creating authentication tokenizer: %w", err)
	}
	userDao, err := user.NewDao(db)
	if err != nil {
		return nil, fmt.Errorf("creating user dao: %w", err)
	}
	socketRunnerCfg := f.socketRunnerConfig(timeFunc)
	socketRunner, err := socketRunnerCfg.NewRunner(log)
	if err != nil {
		return nil, fmt.Errorf("creating socket runner: %w", err)
	}
	wordsReader := bytes.NewReader(e.Words)
	wordValidator, err := word.NewValidator(wordsReader)
	if err != nil {
		return nil, fmt.Errorf("creating word validator: %v", err)
	}
	gameRunnerCfg := f.gameRunnerConfig(timeFunc)
	gameRunner, err := gameRunnerCfg.NewRunner(log, wordValidator, userDao)
	if err != nil {
		return nil, fmt.Errorf("creating game runner: %w", err)
	}
	lobbyCfg := f.lobbyConfig()
	lobby, err := lobbyCfg.NewLobby(log, socketRunner, gameRunner)
	if err != nil {
		return nil, fmt.Errorf("creating lobby: %w", err)
	}
	challenge := server.Challenge{
		Token: f.ChallengeToken,
		Key:   f.ChallengeKey,
	}
	colorCfg := f.colorConfig()
	cfg := server.Config{
		HTTPPort:      f.HTTPPort,
		HTTPSPort:     f.HTTPSPort,
		StopDur:       20 * time.Second, 
		CacheSec:      f.CacheSec,
		Version:       strings.TrimSpace(string(e.Version)),
		TLSCertPEM:    string(e.TLSCertPEM),
		TLSKeyPEM:     string(e.TLSKeyPEM),
		Challenge:     challenge,
		ColorConfig:   colorCfg,
		NoTLSRedirect: f.NoTLSRedirect,
	}
	p := server.Parameters{
		Logger:     log,
		Tokenizer:  tokenizer,
		UserDao:    userDao,
		Lobby:      lobby,
		StaticFS:   e.StaticFS,
		TemplateFS: e.TemplateFS,
	}
	return cfg.NewServer(p)
}
func ( f Flags ) CreateServer ( ctx context . Context , log log . Logger , db * db . Database , e EmbeddedData ) ( * server . Server , error ) { timeFunc := func ( ) int64 { return time . Now ( ) . Unix ( ) } key := make ( [ ] byte , 64 ) if _ , err := crypto_rand . Reader . Read ( key ) ; err != nil { return nil , fmt . Errorf ( " " , err ) } tokenizerCfg := f . tokenizerConfig ( timeFunc ) tokenizer , err := tokenizerCfg . NewTokenizer ( key ) if err != nil { return nil , fmt . Errorf ( " " , err ) } userDao , err := user . NewDao ( db ) if err != nil { return nil , fmt . Errorf ( " " , err ) } socketRunnerCfg := f . socketRunnerConfig ( timeFunc ) socketRunner , err := socketRunnerCfg . NewRunner ( log ) if err != nil { return nil , fmt . Errorf ( " " , err ) } wordsReader := bytes . NewReader ( e . Words ) wordValidator , err := word . NewValidator ( wordsReader ) if err != nil { return nil , fmt . Errorf ( " " , err ) } gameRunnerCfg := f . gameRunnerConfig ( timeFunc ) gameRunner , err := gameRunnerCfg . NewRunner ( log , wordValidator , userDao ) if err != nil { return nil , fmt . Errorf ( " " , err ) } lobbyCfg := f . lobbyConfig ( ) lobby , err := lobbyCfg . NewLobby ( log , socketRunner , gameRunner ) if err != nil { return nil , fmt . Errorf ( " " , err ) } challenge := server . Challenge { Token : f . ChallengeToken , Key : f . ChallengeKey , } colorCfg := f . colorConfig ( ) cfg := server . Config { HTTPPort : f . HTTPPort , HTTPSPort : f . HTTPSPort , StopDur : 20 * time . Second , CacheSec : f . CacheSec , Version : strings . TrimSpace ( string ( e . Version ) ) , TLSCertPEM : string ( e . TLSCertPEM ) , TLSKeyPEM : string ( e . TLSKeyPEM ) , Challenge : challenge , ColorConfig : colorCfg , NoTLSRedirect : f . NoTLSRedirect , } p := server . Parameters { Logger : log , Tokenizer : tokenizer , UserDao : userDao , Lobby : lobby , StaticFS : e . StaticFS , TemplateFS : e . TemplateFS , } return cfg . NewServer ( p ) }
CreateServer creates the server.
CreateServer creates the server .
// should be longer than the PingPeriod of sockets so they can close gracefully