From 2d220fc34bb762ae3075e8ac10acfd1f19c9f710 Mon Sep 17 00:00:00 2001 From: xdrm-brackets Date: Sat, 28 Apr 2018 17:56:37 +0200 Subject: [PATCH] added 'asyncWriter()' behavior + frame interface TODO --- ws/client.go | 12 ++++++++++-- ws/frame.go | 17 +++++++++++++++++ 2 files changed, 27 insertions(+), 2 deletions(-) diff --git a/ws/client.go b/ws/client.go index 07c4c04..82c1acc 100644 --- a/ws/client.go +++ b/ws/client.go @@ -80,9 +80,17 @@ func (c *Client) asyncReader(s *Server) { func (c *Client) asyncWriter(s *Server){ - for buffer := range c.sendc { + for payload := range c.sendc { + + fmt.Printf("Writing '%s'\n", payload) + + // Build Frame + f := BuildFromPayload(payload) + + // Send over socket + c.sock.Write( f.Bytes() ) + - fmt.Printf("Writing '%s'\n", buffer) } diff --git a/ws/frame.go b/ws/frame.go index 935e331..f1f8344 100644 --- a/ws/frame.go +++ b/ws/frame.go @@ -101,4 +101,21 @@ func (f *Frame) ReadPayload(b *bytes.Buffer, s net.Conn) error{ return nil +} + + + + + +// BuildFromPayload builds a frame from only a payload +// (as []byte) +func BuildFromPayload(payload []byte) *Frame { + return nil +} + + +// Bytes returns the BYTE representation of the frame +// for sending over the network (into socket) +func (f *Frame) Bytes() []byte { + return nil } \ No newline at end of file