From 6202728fdcd6a3c2b8bdb59b2ea8c1188cabd51c Mon Sep 17 00:00:00 2001 From: Justin T <37750742+jtieri@users.noreply.github.com> Date: Mon, 9 Dec 2019 21:14:57 -0600 Subject: [PATCH] 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 --- habbgo/server/server.go | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/habbgo/server/server.go b/habbgo/server/server.go index 685906d..cfeae8f 100644 --- a/habbgo/server/server.go +++ b/habbgo/server/server.go @@ -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 }