|
|
@@ -86,7 +86,7 @@ impl BingxSwapWs {
|
|
|
};
|
|
|
|
|
|
/*******公共频道-私有频道数据组装*/
|
|
|
- let ws_param = BingxSwapWsParam {
|
|
|
+ let ws_param = BingxSwapWsParam {
|
|
|
token: "".to_string(),
|
|
|
ws_url: "".to_string(),
|
|
|
ws_ping_interval: 0,
|
|
|
@@ -275,12 +275,10 @@ impl BingxSwapWs {
|
|
|
{
|
|
|
// trace!("原始数据:{:?}",text);
|
|
|
match text.as_str() {
|
|
|
- "Ping" =>{
|
|
|
- return ResponseData::new("".to_string(), -300, "success".to_string(), Value::String(String::from("Pong")))
|
|
|
- }
|
|
|
- _ =>{
|
|
|
-
|
|
|
+ "Ping" => {
|
|
|
+ return ResponseData::new("".to_string(), -300, "success".to_string(), Value::String(String::from("Pong")));
|
|
|
}
|
|
|
+ _ => {}
|
|
|
}
|
|
|
let mut res_data = ResponseData::new("".to_string(), 200, "success".to_string(), Value::Null);
|
|
|
let json_value: serde_json::Value = serde_json::from_str(&text).unwrap();
|
|
|
@@ -291,27 +289,26 @@ impl BingxSwapWs {
|
|
|
if json_value["code"].as_i64() == Option::from(0) {
|
|
|
res_data.code = -201;
|
|
|
res_data.message = "订阅成功".to_string();
|
|
|
- }else{
|
|
|
+ } else {
|
|
|
res_data.code = 400;
|
|
|
res_data.message = "订阅失败".to_string();
|
|
|
}
|
|
|
- }else if json_value["code"].as_i64() == Option::from(0){
|
|
|
+ } else if json_value["code"].as_i64() == Option::from(0) {
|
|
|
res_data.code = 200;
|
|
|
res_data.data = json_value.clone();
|
|
|
|
|
|
//订阅数据 甄别
|
|
|
- let dataType = json_value["dataType"].as_str().unwrap();
|
|
|
- if dataType.contains("@depth"){
|
|
|
+ let data_type = json_value["dataType"].as_str().unwrap();
|
|
|
+ if data_type.contains("@depth") {
|
|
|
res_data.channel = "futures.order_book".to_string();
|
|
|
- }else if dataType.contains("@trade"){
|
|
|
+ } else if data_type.contains("@trade") {
|
|
|
res_data.channel = "futures.trades".to_string();
|
|
|
- }else if dataType.contains("@kline_1m") {
|
|
|
+ } else if data_type.contains("@kline_1m") {
|
|
|
res_data.channel = "futures.candlesticks".to_string();
|
|
|
- }else{
|
|
|
+ } else {
|
|
|
res_data.channel = "未知推送数据".to_string();
|
|
|
}
|
|
|
-
|
|
|
- }else{
|
|
|
+ } else {
|
|
|
res_data.code = -1;
|
|
|
res_data.message = "未知解析".to_string();
|
|
|
}
|