ㅑㅜㅎ
This commit is contained in:
parent
4522a80579
commit
f653cbf551
|
@ -155,6 +155,10 @@ func (s *server) handleRequest(ctx *fasthttp.RequestCtx) {
|
||||||
|
|
||||||
socketCTX := socketHandler.SocketContext(s.ctx)
|
socketCTX := socketHandler.SocketContext(s.ctx)
|
||||||
soc := newSocket(socketHandler, socketCTX, conn, socketID)
|
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)
|
s.stopWg.Add(1)
|
||||||
handleConnection(s, soc, socketHandler)
|
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) {
|
func handleConnection(s *server, soc Socket, socketHandler SocketHandler) {
|
||||||
defer s.stopWg.Done()
|
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{})
|
clientStopChan := make(chan struct{})
|
||||||
handleDoneChan := make(chan struct{})
|
handleDoneChan := make(chan struct{})
|
||||||
|
|
||||||
|
|
|
@ -31,7 +31,7 @@ type SocketHandler interface {
|
||||||
// newSoc := ...
|
// newSoc := ...
|
||||||
// return newSoc
|
// return newSoc
|
||||||
// }
|
// }
|
||||||
OnConnect(soc Socket) Socket
|
OnConnect(soc Socket)
|
||||||
Handle(soc Socket, stopChan <-chan struct{}, doneChan chan<- struct{})
|
Handle(soc Socket, stopChan <-chan struct{}, doneChan chan<- struct{})
|
||||||
// OnDisconnect invoked when client is disconnected
|
// OnDisconnect invoked when client is disconnected
|
||||||
// If you override ths method, must call
|
// If you override ths method, must call
|
||||||
|
|
Loading…
Reference in New Issue
Block a user