make Send() generic with 'io.Writer'
This commit is contained in:
parent
89124221fb
commit
dadd3cd479
|
@ -149,7 +149,7 @@ func readMessage(reader io.Reader) (*Message, error){
|
||||||
|
|
||||||
|
|
||||||
// Send sends a frame over a socket
|
// 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)
|
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]...)
|
writeBuf = append(writeBuf, m.Data[0:m.Size]...)
|
||||||
|
|
||||||
/* (4) Send over socket */
|
/* (4) Send over socket */
|
||||||
_, err := socket.Write(writeBuf)
|
_, err := writer.Write(writeBuf)
|
||||||
if err != nil { return err }
|
if err != nil { return err }
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
|
|
Loading…
Reference in New Issue