From 52f00b341d5d5c42f2a1434725431f00743ece90 Mon Sep 17 00:00:00 2001 From: Kevin Cotugno Date: Mon, 18 Sep 2017 21:17:12 -0700 Subject: [PATCH] Begin websocket client --- websocket/client.go | 43 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 43 insertions(+) create mode 100644 websocket/client.go diff --git a/websocket/client.go b/websocket/client.go new file mode 100644 index 0000000..ffab889 --- /dev/null +++ b/websocket/client.go @@ -0,0 +1,43 @@ +package websocket + +import ( + "github.com/gorilla/websocket" +) + +const ENDPOINT = "wss://ws-feed.gdax.com" + +type Client struct { + Disconnect chan int + + conn *websocket.Conn +} + +func NewClient() *Client { + c := Client{} + c.writer = make(chan string) + + return &c +} + +func (c *Client) Open() error { + c.conn, _, err := websocket.Dial(ENDPOINT, nil) + if err != nil { + return erro + } + + go func () { + var buf []byte + for true { + _, buf, _ = c.conn.ReadMessage() + log.Write(string(bug)) + } + }() + + go func () { + select { + case message <- c.writer: + } + }() + + return nil +}