From f653cbf55137d6b931c795499200879623251859 Mon Sep 17 00:00:00 2001 From: crusader Date: Tue, 28 Nov 2017 00:42:27 +0900 Subject: [PATCH] =?UTF-8?q?=E3=85=91=E3=85=9C=E3=85=8E?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- server.go | 8 ++++---- socket_handler.go | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/server.go b/server.go index 7b07cae..a3d932d 100644 --- a/server.go +++ b/server.go @@ -155,6 +155,10 @@ func (s *server) handleRequest(ctx *fasthttp.RequestCtx) { socketCTX := socketHandler.SocketContext(s.ctx) soc := newSocket(socketHandler, socketCTX, conn, socketID) + logging.Logger().Debug(fmt.Sprintf("Server: Client[%s] is connected.", soc.RemoteAddr())) + + socketHandler.addSocket(soc) + socketHandler.OnConnect(soc) s.stopWg.Add(1) handleConnection(s, soc, socketHandler) @@ -171,10 +175,6 @@ func (s *server) handleError(ctx *fasthttp.RequestCtx, status int, reason error) func handleConnection(s *server, soc Socket, socketHandler SocketHandler) { defer s.stopWg.Done() - logging.Logger().Debug(fmt.Sprintf("Server: Client[%s] is connected.", soc.RemoteAddr())) - soc = socketHandler.OnConnect(soc) - socketHandler.addSocket(soc) - clientStopChan := make(chan struct{}) handleDoneChan := make(chan struct{}) diff --git a/socket_handler.go b/socket_handler.go index 48a3201..5680182 100644 --- a/socket_handler.go +++ b/socket_handler.go @@ -31,7 +31,7 @@ type SocketHandler interface { // newSoc := ... // return newSoc // } - OnConnect(soc Socket) Socket + OnConnect(soc Socket) Handle(soc Socket, stopChan <-chan struct{}, doneChan chan<- struct{}) // OnDisconnect invoked when client is disconnected // If you override ths method, must call