|
|
@@ -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()) {
|