This commit is contained in:
jwlee
2024-06-08 14:45:14 +09:00
parent 3b84645a04
commit 2247bb36f5
2 changed files with 60 additions and 34 deletions

View File

@@ -196,7 +196,7 @@ namespace BitgetAPI.WebService
return returnJsonData;
}
public async void BitGetWebSocektStart(CommonProperty.BitgetWebSocketType bitgetWebSocketType, string chnnelType)
public async void BitGetWebSocektStart(CommonProperty.BitgetWebSocketType bitgetWebSocketType, Dictionary<string, object> dic)
{
string apiUrl = "https://api.upbit.com/v1/market/all?isDetails=true";
@@ -228,24 +228,6 @@ namespace BitgetAPI.WebService
// 연결이 성공적으로 이루어지면 처리할 코드 작성
Console.WriteLine("WebSocket 연결 성공");
// Json String 만들기
// 종목별 Ticker 구독하기
var dic = new Dictionary<string, object>();
dic.Add("op", "subscribe");
var argsList = new List<Dictionary<string, object>>();
foreach (var marketInfo in commonProperty.marketInfoList)
{
var args = new Dictionary<string, object>();
args.Add("instType", "USDT-FUTURES");
args.Add("channel", chnnelType);
args.Add("instId", marketInfo.MarketName);
argsList.Add(args);
}
dic.Add("args", argsList)
;
//var jsonDataText = "{\"op\":\"subscribe\",\"args\":[{\"instType\":\"SPOT\",\"channel\":\"ticker\",\"instId\":\"ETHUSDT\"}, {\"instType\":\"SPOT\",\"channel\":\"ticker\",\"instId\":\"BTCUSDT\"}]}";
var jsonData = JsonConvert.SerializeObject(dic);
@@ -293,6 +275,8 @@ namespace BitgetAPI.WebService
DateTime dt = new DateTime(1970, 01, 01);
tickerList.reciveTime = dt.AddMilliseconds(Convert.ToDouble(tickerList.ts)).ToLocalTime();
var test = 0;
/*
// 웹소켓 티커 리스트에 추가
var searchIndex = commonProperty.webSocketCandles.IndexOf(i => i.instId == tickerList.instId);
if (searchIndex < 0)
@@ -405,6 +389,7 @@ namespace BitgetAPI.WebService
}
}
*/
}
break;
case CommonProperty.BitgetWebSocketType.캔들정보:
@@ -525,11 +510,11 @@ namespace BitgetAPI.WebService
finally
{
//if (webSocket.State == WebSocketState.Open)
//await webSocket.CloseAsync(WebSocketCloseStatus.NormalClosure, "WebSocket 연결 종료", CancellationToken.None);
//await webSocket.CloseAsync(WebSocketCloseStatus.NormalClosure, "WebSocket 연결 종료", CancellationToken.None);
webSocket.Dispose();
// 웹소켓 재귀
BitGetWebSocektStart(bitgetWebSocketType, chnnelType);
BitGetWebSocektStart(bitgetWebSocketType, dic);
}
}