ing
This commit is contained in:
parent
4eaa31788d
commit
83feb109dc
|
@ -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.")
|
||||
}
|
||||
|
|
|
@ -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
|
||||
}
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in New Issue
Block a user