From 83feb109dc4a9e1dbeae6399965ac23295e54ace Mon Sep 17 00:00:00 2001 From: crusader Date: Mon, 27 Nov 2017 20:48:10 +0900 Subject: [PATCH] ing --- server.go | 7 +++++-- socket.go | 2 +- socket_context.go | 2 +- 3 files changed, 7 insertions(+), 4 deletions(-) diff --git a/server.go b/server.go index 70894c5..40d7be1 100644 --- a/server.go +++ b/server.go @@ -19,11 +19,11 @@ type Server interface { Context() ServerContext } -func New(sh ServerHandler) Server { +func New(serverCTX ServerContext, sh ServerHandler) Server { s := &server{ sh: sh, } - s.ctx = NewServerContext(nil) + s.ctx = serverCTX return s } @@ -42,6 +42,9 @@ type server struct { } func (s *server) Start() error { + if nil == s.ctx { + logging.Logger().Panic("Server: server context must be specified.") + } if nil == s.sh { logging.Logger().Panic("Server: server handler must be specified.") } diff --git a/socket.go b/socket.go index 5b6aa83..eedfcc4 100644 --- a/socket.go +++ b/socket.go @@ -156,7 +156,7 @@ func newSocket(serverCTX ServerContext, id string, conn *websocket.Conn, sh Sock if 0 < sh.GetReadTimeout() { s.SetReadDeadline(time.Now().Add(sh.GetReadTimeout() * time.Second)) } - s.ctx = NewSocketContext(serverCTX) + s.ctx = newSocketContext(serverCTX) return s } diff --git a/socket_context.go b/socket_context.go index fe997a3..f0b32ab 100644 --- a/socket_context.go +++ b/socket_context.go @@ -9,7 +9,7 @@ type SocketContext interface { ServerContext() ServerContext } -func NewSocketContext(serverCTX ServerContext) SocketContext { +func newSocketContext(serverCTX ServerContext) SocketContext { sCTX := &socketContext{} sCTX.Context = cuc.NewContext(serverCTX) sCTX.serverCTX = serverCTX