This repository has been archived on 2022-11-30. You can view files and clone it, but cannot push or open issues or pull requests.
tacitus/websocket/client.go

44 lines
570 B
Go
Raw Normal View History

2017-09-18 21:17:12 -07:00
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
}