package main

import (
	"log/slog"
	"os"
	"slgserver/config"
	"slgserver/net"
	"slgserver/server/chatserver"
)

func getChatServerAddr() string {
	host := config.GetString("chatserver.host", "")
	port := config.GetString("chatserver.port", "8002")
	return host + ":" + port
}

func main() {
	if wd, err := os.Getwd(); err == nil {
		slog.Info("working directory", "dir", wd)
	} else {
		slog.Warn("get working directory failed", "error", err)
	}
	chatserver.Init()
	needSecret := config.GetBool("chatserver.need_secret", false)
	s := net.NewServer(getChatServerAddr(), needSecret)
	s.Router(chatserver.MyRouter)
	s.Start()
}
