diff --git a/socket.go b/socket.go index 965b4b8..7dae5ae 100644 --- a/socket.go +++ b/socket.go @@ -193,6 +193,21 @@ func (s *fasthttpWebSocket) WriteMessage(messageType int, data []byte) error { return s.Conn.WriteMessage(messageType, data) } +func (s *fasthttpWebSocket) WriteMessageUseWriter(messageType int, data []byte) error { + wc, err := s.NextWriter(messageType) + if nil != err { + return err + } + + defer func() { + wc.Close() + }() + + _, err = wc.Write(data) + + return err +} + func (s *fasthttpWebSocket) Close() error { err := s.Conn.Close() releaseSocket(s)