Răsfoiți Sursa

binan 接口提交

875428575@qq.com 2 ani în urmă
părinte
comite
09d1bbd83b
1 a modificat fișierele cu 11 adăugiri și 13 ștergeri
  1. 11 13
      src/exchange_libs.rs

+ 11 - 13
src/exchange_libs.rs

@@ -537,7 +537,7 @@ impl SocketTool {
             subscription: subscription,
         }
     }
-    pub(crate) fn run(&self, exc_name: String, parse_fn:  impl Fn()) {
+    pub(crate) fn run(&self, parse_fn: impl Fn()) {
         while true {//一个粗糙的 断开重连操作
             /*****消息溜***/
             let mut stdout = io::stdout();
@@ -597,11 +597,14 @@ impl SocketTool {
                     match msg {
                         Ok(Message::Text(text)) => {
                             writeln!(stdout, "{:?}", text).unwrap();
-                            if exc_name == "binance" {
-                                SocketTool::hook_fn_binance(text, parse_fn)
-                            } else if exc_name == "okx" {
-                                SocketTool::hook_fn_okx(text, parse_fn)
-                            }
+
+                            parse_fn(text);
+
+                            // if exc_name == "binance" {
+                            //     SocketTool::hook_fn_binance(text, )
+                            // } else if exc_name == "okx" {
+                            //     SocketTool::hook_fn_okx(text, parse_fn)
+                            // }
                         }
                         Ok(Message::Ping(_)) | Ok(Message::Pong(_)) | Ok(Message::Close(_)) => {
                             socket.write_message(Message::text("pong"));
@@ -655,12 +658,7 @@ impl SocketTool {
                     match msg {
                         Ok(Message::Text(text)) => {
                             writeln!(stdout, "{:?}", text).unwrap();
-                            println!("??????????---{0}--", exc_name);
-                            if exc_name == "binance" {
-                                SocketTool::hook_fn_binance(text, parse_fn)
-                            } else if exc_name == "okx" {
-                                SocketTool::hook_fn_okx(text, parse_fn)
-                            }
+                            parse_fn(text);
                         }
                         Ok(Message::Ping(_)) | Ok(Message::Pong(_)) | Ok(Message::Close(_)) => {
                             socket.write_message(Message::Pong(vec![]))
@@ -775,7 +773,7 @@ impl SocketTool {
                                            btree_map,
                                            subscription,
         );
-        biance_socke.run("binance".to_string(), parse_fn);
+        biance_socke.run(parse_fn);
     }
 
     fn hook_fn_binance(message: String, parse_fn: impl Fn()) {