diff --git a/server.go b/server.go index 1dc2a72..cc38ad0 100644 --- a/server.go +++ b/server.go @@ -151,7 +151,6 @@ func (s *server) handleRequest(ctx *fasthttp.RequestCtx) { } socketCTX := socketHandler.SocketContext(s.ctx) - logging.Logger().Debug(fmt.Sprintf("Server: Client is SocketContext.")) soc := newSocket(socketHandler, socketCTX, conn, socketID) logging.Logger().Debug(fmt.Sprintf("Server: Client[%s] is connected.", soc.RemoteAddr())) diff --git a/socket.go b/socket.go index 624723d..715db84 100644 --- a/socket.go +++ b/socket.go @@ -3,7 +3,6 @@ package websocket_fasthttp import ( "io" "net" - "sync" "time" "git.loafle.net/commons_go/websocket_fasthttp/websocket" @@ -148,7 +147,7 @@ type Socket interface { } func newSocket(socketHandler SocketHandler, socketCTX SocketContext, conn *websocket.Conn, id string) Socket { - s := retainSocket() + s := &fasthttpWebSocket{} s.Conn = conn s.sh = socketHandler s.id = id @@ -220,7 +219,6 @@ func (s *fasthttpWebSocket) WriteMessage(messageType int, data []byte) error { func (s *fasthttpWebSocket) Close() error { err := s.Conn.Close() - releaseSocket(s) return err } @@ -280,23 +278,23 @@ func (s *fasthttpWebSocket) Close() error { // return sc.s.SetWriteDeadline(t) // } -var socketPool sync.Pool +// var socketPool sync.Pool -func retainSocket() *fasthttpWebSocket { - v := socketPool.Get() - if v == nil { - return &fasthttpWebSocket{} - } - return v.(*fasthttpWebSocket) -} +// func retainSocket() *fasthttpWebSocket { +// v := socketPool.Get() +// if v == nil { +// return &fasthttpWebSocket{} +// } +// return v.(*fasthttpWebSocket) +// } -func releaseSocket(s *fasthttpWebSocket) { - s.sh = nil - s.ctx = nil - s.id = "" +// func releaseSocket(s *fasthttpWebSocket) { +// s.sh = nil +// s.ctx = nil +// s.id = "" - socketPool.Put(s) -} +// socketPool.Put(s) +// } // var socketConnPool sync.Pool