ing
This commit is contained in:
parent
072d6f11a8
commit
760e6b8ae1
|
@ -131,8 +131,9 @@ func (s *server) handleRequest(ctx *fasthttp.RequestCtx) {
|
|||
s.handleError(ctx, fasthttp.StatusInternalServerError, err)
|
||||
return
|
||||
}
|
||||
|
||||
s.stopWg.Add(1)
|
||||
go handleConnection(s, ctx, conn, socketHandler)
|
||||
go handleConnection(s, conn, socketHandler)
|
||||
})
|
||||
|
||||
}
|
||||
|
@ -144,7 +145,7 @@ func (s *server) handleError(ctx *fasthttp.RequestCtx, status int, reason error)
|
|||
s.sh.OnError(ctx, status, reason)
|
||||
}
|
||||
|
||||
func handleConnection(s *server, ctx *fasthttp.RequestCtx, conn *websocket.Conn, handler SocketHandler) {
|
||||
func handleConnection(s *server, conn *websocket.Conn, handler SocketHandler) {
|
||||
defer s.stopWg.Done()
|
||||
|
||||
logging.Logger.Debug(fmt.Sprintf("Server: Client[%s] is connected.", conn.RemoteAddr()))
|
||||
|
@ -160,8 +161,8 @@ func handleConnection(s *server, ctx *fasthttp.RequestCtx, conn *websocket.Conn,
|
|||
<-handleDoneChan
|
||||
case <-handleDoneChan:
|
||||
close(clientStopChan)
|
||||
conn.Close()
|
||||
logging.Logger.Debug(fmt.Sprintf("Server: Client[%s] is disconnected.", conn.RemoteAddr()))
|
||||
conn.Close()
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -6,6 +6,6 @@ import (
|
|||
)
|
||||
|
||||
type SocketHandler interface {
|
||||
Handshake(ctx *fasthttp.RequestCtx) (bool, *fasthttp.ResponseHeader)
|
||||
Handshake(ctx *fasthttp.RequestCtx) (connectable bool, extensionsHeader *fasthttp.ResponseHeader)
|
||||
Handle(conn *websocket.Conn, stopChan <-chan struct{}, doneChan chan<- struct{})
|
||||
}
|
||||
|
|
|
@ -11,6 +11,7 @@ type SocketHandlers struct {
|
|||
func (sh *SocketHandlers) Handshake(ctx *fasthttp.RequestCtx) (bool, *fasthttp.ResponseHeader) {
|
||||
return true, nil
|
||||
}
|
||||
|
||||
func (sh *SocketHandlers) Handle(conn *websocket.Conn, stopChan <-chan struct{}, doneChan chan<- struct{}) {
|
||||
// no op
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user