func (h *HUOBI) WebsocketClient() { events := make(map[string]func(message []byte, output chan socketio.Message)) events["request"] = h.OnRequest events["message"] = h.OnMessage HuobiSocket = &socketio.SocketIO{ Version: 0.9, OnConnect: h.OnConnect, OnEvent: events, OnError: h.OnError, OnDisconnect: h.OnDisconnect, } for h.Enabled && h.Websocket { err := socketio.ConnectToSocket(HUOBI_SOCKETIO_ADDRESS, HuobiSocket) if err != nil { log.Printf("%s Unable to connect to Websocket. Err: %s\n", err) continue } log.Printf("%s Disconnected from Websocket.") } }
func (b *BTCChina) WebsocketClient() { events := make(map[string]func(message []byte, output chan socketio.Message)) events["grouporder"] = b.OnGroupOrder events["ticker"] = b.OnTicker events["trade"] = b.OnTrade BTCChinaSocket = &socketio.SocketIO{ Version: 1, OnConnect: b.OnConnect, OnEvent: events, OnError: b.OnError, OnMessage: b.OnMessage, OnDisconnect: b.OnDisconnect, } for b.Enabled && b.Websocket { err := socketio.ConnectToSocket(BTCCHINA_SOCKETIO_ADDRESS, BTCChinaSocket) if err != nil { log.Printf("%s Unable to connect to Websocket. Err: %s\n", err) continue } log.Printf("%s Disconnected from Websocket.") } }