Ver código fonte

优化代码

875428575@qq.com 2 anos atrás
pai
commit
9678765a0b
1 arquivos alterados com 12 adições e 40 exclusões
  1. 12 40
      exchanges/src/kuconin_swap_ws.rs

+ 12 - 40
exchanges/src/kuconin_swap_ws.rs

@@ -28,11 +28,10 @@ pub struct WsParam {
     pub ws_ping_timeout: i64,
 }
 
-#[derive(Clone)]
+#[derive(Clone)]                        //订阅枚举
 pub enum SubscribeType {
     PuContractMarketLevel2Depth50,
-    // level2的50檔全量數據推送頻道
-    PuContractMarketExecution, //  成交记录
+    PuContractMarketExecution,
 
     PrContractAccountWallet,
     PrContractPosition,
@@ -42,20 +41,13 @@ pub enum SubscribeType {
 
 #[derive(Clone)]
 pub struct KuconinSwapWs {
-    request_url: String,
-
-    proxy: ParsingDetail,
-    // ip: String,
-    // port: u16,
-    login_param: BTreeMap<String, String>,
-    // token: String,
-    // ws_url: String,
-    // ws_ping_interval: i64,
-    // ws_ping_timeout: i64,
-    ws_param: WsParam,
-    symbol_s: Vec<String>,
-    subscribe_types: Vec<SubscribeType>,
-    sender: mpsc::Sender<ResponseData>,
+    request_url: String,                    //实际ws 链接地址
+    proxy: ParsingDetail,                   //代理信息
+    login_param: BTreeMap<String, String>,  //登陆数据
+    ws_param: WsParam,                      //kuconis特殊参数
+    symbol_s: Vec<String>,                  //订阅币对
+    subscribe_types: Vec<SubscribeType>,    //订阅信息
+    sender: mpsc::Sender<ResponseData>,     //数据通道
 }
 
 impl KuconinSwapWs {
@@ -262,8 +254,7 @@ impl KuconinSwapWs {
 
     //代理
     fn proxy_subscription(&self, mut web_socket: WebSocket<ProxyAutoStream>,
-                          subscription: Vec<String>,
-    )
+                          subscription: Vec<String>)
     {
         /*****消息溜***/
         let mut stdout = io::stdout();
@@ -326,30 +317,11 @@ impl KuconinSwapWs {
         }
         web_socket.close(None).unwrap();
     }
+
     //非代理
     fn subscription(&self, mut web_socket: WebSocket<AutoStream>,
-                    subscription: Vec<String>,
-    )
-
+                    subscription: Vec<String>)
     {
-        /*****消息溜***/
-        // let  stdout = io::stdout();
-        // let mut stderr = io::stderr();
-        /*****是否需要登陆****/
-        // if self.is_login {
-        //     println!("----需要登陆");
-        //     // let login_json_str = self.log_in_to_str();
-        //     // web_socket.write_message(Message::Text(login_json_str)).unwrap();
-        //     // thread::sleep(Duration::from_secs(1));
-        // } else {
-        //     println!("----no longin(不需要登陆)");
-        // }
-        /******订阅信息********/
-        // let sub_json = subscription.clone();
-        // println!("--订阅内容:{:?}", sub_json);
-        // let sub_json_str = sub_json.to_string();
-        // web_socket.write_message(Message::Text(sub_json_str))
-        //     .unwrap();
         loop {
             let msg = web_socket.read_message();
             match msg {