|
|
@@ -13,7 +13,7 @@ use tokio::net::TcpStream;
|
|
|
use tokio::sync::Mutex;
|
|
|
use tokio_tungstenite::{connect_async, MaybeTlsStream, WebSocketStream};
|
|
|
use tokio_tungstenite::tungstenite::{Error, Message};
|
|
|
-use tracing::trace;
|
|
|
+use tracing::{info, trace};
|
|
|
|
|
|
use crate::proxy;
|
|
|
use crate::proxy::{ProxyEnum, ProxyResponseEnum};
|
|
|
@@ -85,12 +85,50 @@ impl AbstractWsMode {
|
|
|
let write_clone3 = Arc::clone(&write_arc);
|
|
|
let ws_to_stdout = async {
|
|
|
while let Some(message) = read.next().await {
|
|
|
+ if !bool_v1.load(Ordering::Relaxed) {
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+
|
|
|
let mut write_lock3 = write_clone3.lock().await;
|
|
|
let response_data = AbstractWsMode::analysis_message(message, message_text, message_ping, message_pong);
|
|
|
// let response_data = func(message);
|
|
|
if response_data.is_some() {
|
|
|
- let mut data = response_data.unwrap();
|
|
|
- data.label = lable.clone();
|
|
|
+ let data = response_data.unwrap();
|
|
|
+
|
|
|
+ if data.code == "200" {
|
|
|
+ let mut data_c = data.clone();
|
|
|
+ data_c.time = chrono::Utc::now().timestamp_micros();
|
|
|
+ data_c.label = lable.clone();
|
|
|
+
|
|
|
+ if data_c.label.contains("gate_usdt_swap") {
|
|
|
+ if data_c.channel == "futures.order_book" {
|
|
|
+ if read_tx.len() == 0 {
|
|
|
+ read_tx.unbounded_send(data_c).unwrap();
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ read_tx.unbounded_send(data_c).unwrap();
|
|
|
+ }
|
|
|
+ } else if data_c.label.contains("binance_usdt_swap") {
|
|
|
+ if data_c.channel == "bookTicker" {
|
|
|
+ if read_tx.len() == 0 {
|
|
|
+ read_tx.unbounded_send(data_c).unwrap();
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ read_tx.unbounded_send(data_c).unwrap();
|
|
|
+ }
|
|
|
+ } else if data_c.label.contains("bybit_usdt_swap") {
|
|
|
+ if data_c.channel == "orderbook" {
|
|
|
+ if read_tx.len() == 0 {
|
|
|
+ read_tx.unbounded_send(data_c).unwrap();
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ read_tx.unbounded_send(data_c).unwrap();
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ read_tx.unbounded_send(data_c).unwrap();
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
let code = data.code.clone();
|
|
|
/*
|
|
|
200 -正确返回
|
|
|
@@ -102,9 +140,6 @@ impl AbstractWsMode {
|
|
|
*/
|
|
|
match code.as_str() {
|
|
|
"200" => {
|
|
|
- if bool_v1.load(Ordering::Relaxed) {
|
|
|
- read_tx.unbounded_send(data).unwrap();
|
|
|
- }
|
|
|
}
|
|
|
"-200" => {
|
|
|
//登录成功
|