From dadd3cd479bce87eb9ece916ee7d673d0fcf7a31 Mon Sep 17 00:00:00 2001 From: xdrm-brackets Date: Sat, 5 May 2018 23:53:38 +0200 Subject: [PATCH] make Send() generic with 'io.Writer' --- ws/message.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/ws/message.go b/ws/message.go index e577eb7..58b6f5f 100644 --- a/ws/message.go +++ b/ws/message.go @@ -149,7 +149,7 @@ func readMessage(reader io.Reader) (*Message, error){ // Send sends a frame over a socket -func (m Message) Send(socket net.Conn) error { +func (m Message) Send(writer io.Writer) error { header := make([]byte, 0, maximumHeaderSize) @@ -190,7 +190,7 @@ func (m Message) Send(socket net.Conn) error { writeBuf = append(writeBuf, m.Data[0:m.Size]...) /* (4) Send over socket */ - _, err := socket.Write(writeBuf) + _, err := writer.Write(writeBuf) if err != nil { return err } return nil