Open Sexy-Commando opened 3 months ago
what do you want to do in the wsKlineHandler ? @Sexy-Commando
the stream arrives in variable event in wsKlineHandler,but the pairs come as a whole.i want to separate the pairs as separate strings. this is the stream i get
ETHBTC 0.05150000
LTCBTC 0.00110300
BTCUSDT 66311.48000000
lets say i want to add them to database and i need to separate the stream i get into separate strings
and add it to db.
ETHBTC 0.05150000 and add to database
,then LTCBTC 0.00110300 add to database
,BTCUSDT 66311.48000000 add to database etc...
so how do i split the stream i get?
can it be done? @xyq-c-cpp
why the pairs come as a whole? it's just a single object pointer in wsKlineHandler, you know, you just handle the single object pointer and then add it to database. @Sexy-Commando
but how do i do that? i have no idea. could you provide an example? @xyq-c-cpp
i want to process the stream as it arrives and i have no idea how to do that. the stream arrives in this variable event,and i need to separate the pairs so that i can process them.so i can't loop through it,i can't use string separator,i can't add it to a map.how to do this?
func main() { pairs := map[string]string{"ETHBTC":"1s","BTCUSDT":"1s","LTCBTC":"1s"} wsKlineHandler := func(event *binance.WsKlineEvent) { fmt.Println(event.Symbol,event.Kline.Open) } errHandler := func(err error) { fmt.Println(err) } doneC, _, err := binance.WsCombinedKlineServe(pairs, wsKlineHandler, errHandler) if err != nil { fmt.Println(err) return } <-doneC }
this is the stream i get
ETHBTC 0.05150000 LTCBTC 0.00110300 BTCUSDT 66311.48000000