update server to have config ref

added a reference to the config struct created in main so that config settings can be obtained throughout the server
This commit is contained in:
Justin T 2019-12-09 21:14:57 -06:00
parent a3142047e5
commit 6202728fdc
1 changed files with 9 additions and 2 deletions

View File

@ -2,6 +2,7 @@ package server
import (
"bufio"
"github.com/jtieri/HabbGo/habbgo/utils"
"log"
"net"
"os"
@ -13,12 +14,18 @@ type server struct {
host string
port int16
maxConns int
config *utils.Config
activeSessions []*Session
}
// New returns a pointer to a newly allocated server struct.
func New(port int16, host string, maxConns int) *server {
server := &server{port: port, host: host, maxConns: maxConns}
func New(config *utils.Config) *server {
server := &server{
port: config.Server.Port,
host: config.Server.Host,
maxConns: config.Server.MaxConns,
config: config,
}
return server
}