Begin websocket client

This commit is contained in:
Kevin Cotugno 2017-09-18 21:17:12 -07:00
parent c0448451e3
commit 52f00b341d

43
websocket/client.go Normal file
View File

@ -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
}