예제 #1
0
func (h *HUOBI) OnConnect(output chan socketio.Message) {
	if h.Verbose {
		log.Printf("%s Connected to Websocket.", h.GetName())
	}

	for _, x := range h.EnabledPairs {
		currency := StringToLower(x)
		msg := h.BuildHuobiWebsocketRequestExtra(HUOBI_SOCKET_REQ_SUBSCRIBE, 100, h.BuildHuobiWebsocketParamsList(HUOBI_SOCKET_MARKET_OVERVIEW, currency, "pushLong", "", "", "", "", ""))
		result, err := JSONEncode(msg)
		if err != nil {
			log.Println(err)
		}
		output <- socketio.CreateMessageEvent("request", string(result), nil, HuobiSocket.Version)
	}
}
예제 #2
0
func (b *BTCChina) OnConnect(output chan socketio.Message) {
	if b.Verbose {
		log.Printf("%s Connected to Websocket.", b.GetName())
	}

	currencies := []string{}
	for _, x := range b.EnabledPairs {
		currency := StringToLower(x[3:] + x[0:3])
		currencies = append(currencies, currency)
	}
	endpoints := []string{"marketdata", "grouporder"}

	for _, x := range endpoints {
		for _, y := range currencies {
			channel := fmt.Sprintf(`"%s_%s"`, x, y)
			if b.Verbose {
				log.Printf("%s Websocket subscribing to channel: %s.", b.GetName(), channel)
			}
			output <- socketio.CreateMessageEvent("subscribe", channel, b.OnMessage, BTCChinaSocket.Version)
		}
	}
}