From fbae725040e25872ac771b9fd314b247634d146f Mon Sep 17 00:00:00 2001 From: Arsen Musayelyan Date: Mon, 16 May 2022 15:42:15 -0700 Subject: [PATCH] Add (*Server).HandleConn() --- server/server.go | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/server/server.go b/server/server.go index 96e411f..73f1f45 100644 --- a/server/server.go +++ b/server/server.go @@ -278,7 +278,14 @@ func (s *Server) ServeWS(ctx context.Context, addr string, cf codec.CodecFunc) ( return server.ListenAndServe() } -// handleConn handles a listener connection +// ServeConn uses the provided connection to serve the client. +// This may be useful if something other than a net.Listener +// needs to be used +func (s *Server) ServeConn(ctx context.Context, conn io.ReadWriter, cf codec.CodecFunc) { + s.handleConn(ctx, cf(conn)) +} + +// handleConn handles a connection func (s *Server) handleConn(pCtx context.Context, c codec.Codec) { codecMtx := &sync.Mutex{}