|
|
@@ -53,18 +53,18 @@ impl OkxSwapWs {
|
|
|
/*******************************************************************************************************/
|
|
|
/*****************************************获取一个对象****************************************************/
|
|
|
/*******************************************************************************************************/
|
|
|
- pub fn new(is_colo: bool,
|
|
|
- login_param: BTreeMap<String, String>,
|
|
|
- ws_type: OkxWsType,
|
|
|
- sender: Sender<ResponseData>,
|
|
|
+ pub fn new(is_colo: bool,
|
|
|
+ login_param: BTreeMap<String, String>,
|
|
|
+ ws_type: OkxWsType,
|
|
|
+ sender: Sender<ResponseData>,
|
|
|
) -> OkxSwapWs
|
|
|
{
|
|
|
return OkxSwapWs::new_label("default-OkxSwapWs".to_string(), is_colo, login_param, ws_type, sender);
|
|
|
}
|
|
|
- pub fn new_label(label: String, is_colo: bool,
|
|
|
- login_param: BTreeMap<String, String>,
|
|
|
- ws_type: OkxWsType,
|
|
|
- sender: Sender<ResponseData>,
|
|
|
+ pub fn new_label(label: String, is_colo: bool,
|
|
|
+ login_param: BTreeMap<String, String>,
|
|
|
+ ws_type: OkxWsType,
|
|
|
+ sender: Sender<ResponseData>,
|
|
|
) -> OkxSwapWs
|
|
|
{
|
|
|
if is_colo {
|
|
|
@@ -309,7 +309,7 @@ impl OkxSwapWs {
|
|
|
|
|
|
//非代理
|
|
|
async fn subscription(&self, mut web_socket: WebSocket<AutoStream>,
|
|
|
- subscription: String)
|
|
|
+ subscription: String)
|
|
|
{
|
|
|
let lable = self.label.clone();
|
|
|
/*****订阅***/
|
|
|
@@ -350,6 +350,8 @@ impl OkxSwapWs {
|
|
|
//数据解析
|
|
|
pub fn ok_text(lable: String, text: String) -> ResponseData
|
|
|
{
|
|
|
+
|
|
|
+ println!("?????{}",text);
|
|
|
let mut res_data = ResponseData::new(lable, "200".to_string(), "success".to_string(), "".to_string());
|
|
|
let json_value: serde_json::Value = serde_json::from_str(&text).unwrap();
|
|
|
if json_value.get("event").is_some() {//订阅返回
|
|
|
@@ -363,7 +365,13 @@ impl OkxSwapWs {
|
|
|
res_data.data = text
|
|
|
}
|
|
|
} else {
|
|
|
- res_data.data = text
|
|
|
+ if json_value.get("arg").is_some() && json_value.get("data").is_some() {
|
|
|
+ res_data.channel = json_value["arg"]["channel"].to_string();
|
|
|
+ res_data.data = json_value["data"].to_string();
|
|
|
+ }else{
|
|
|
+ res_data.data = text;
|
|
|
+ res_data.channel = "未知频道".to_string();
|
|
|
+ }
|
|
|
}
|
|
|
res_data
|
|
|
}
|