fn handle_msg(&self, txt: &str) -> bool {
        match (self.on_misc_msg)(txt) {
            MiscMessage::Misc => false,
            MiscMessage::Pong => {
                self.num_unanswered_ping.store(0, Ordering::Release);
                false
            }
            MiscMessage::Reconnect => {
                // self.reconnect();
                std::thread::sleep(Duration::from_secs(5));
                std::process::exit(0); // fail fast, pm2 will restart
            }
            MiscMessage::WebSocket(ws_msg) => {
                let ret = self.ws_stream.lock().unwrap().write_message(ws_msg);
                if let Err(err) = ret {
                    error!("{}", err);
                }
                false
            }
            MiscMessage::Normal => {
                if self.exchange == super::mxc::EXCHANGE_NAME
                    && self.url.as_str() == super::mxc::SPOT_WEBSOCKET_URL
                {
                    // special logic for MXC Spot
                    match txt.strip_prefix("42") {
                        Some(msg) => (self.on_msg.lock().unwrap())(msg.to_string()),
                        None => error!(
                            "{}, Not possible, should be handled by {}.on_misc_msg() previously",
                            txt, self.exchange
                        ),
                    }
                } else {
                    (self.on_msg.lock().unwrap())(txt.to_string());
                }
                true
            }
        }
    }
// Handle a text msg from Message::Text or Message::Binary
// Returns true if gets a normal message, otherwise false
Handle a text msg from Message::Text or Message::Binary
Returns true if gets a normal message, otherwise false
Handle a text msg from Message :: Text or Message :: Binary Returns true if gets a normal message otherwise false
fn handle_msg(&self, txt: &str) -> bool {
        match (self.on_misc_msg)(txt) {
            MiscMessage::Misc => false,
            MiscMessage::Pong => {
                self.num_unanswered_ping.store(0, Ordering::Release);
                false
            }
            MiscMessage::Reconnect => {
                // self.reconnect();
                std::thread::sleep(Duration::from_secs(5));
                std::process::exit(0); // fail fast, pm2 will restart
            }
            MiscMessage::WebSocket(ws_msg) => {
                let ret = self.ws_stream.lock().unwrap().write_message(ws_msg);
                if let Err(err) = ret {
                    error!("{}", err);
                }
                false
            }
            MiscMessage::Normal => {
                if self.exchange == super::mxc::EXCHANGE_NAME
                    && self.url.as_str() == super::mxc::SPOT_WEBSOCKET_URL
                {
                    // special logic for MXC Spot
                    match txt.strip_prefix("42") {
                        Some(msg) => (self.on_msg.lock().unwrap())(msg.to_string()),
                        None => error!(
                            "{}, Not possible, should be handled by {}.on_misc_msg() previously",
                            txt, self.exchange
                        ),
                    }
                } else {
                    (self.on_msg.lock().unwrap())(txt.to_string());
                }
                true
            }
        }
    }
fn handle_msg ( & self , txt : & str ) -> bool { match ( self . on_misc_msg ) ( txt ) { MiscMessage :: Misc => false , MiscMessage :: Pong => { self . num_unanswered_ping . store ( 0 , Ordering :: Release ) ; false } MiscMessage :: Reconnect => { // self.reconnect(); std :: thread :: sleep ( Duration :: from_secs ( 5 ) ) ; std :: process :: exit ( 0 ) ; // fail fast, pm2 will restart } MiscMessage :: WebSocket ( ws_msg ) => { let ret = self . ws_stream . lock ( ) . unwrap ( ) . write_message ( ws_msg ) ; if let Err ( err ) = ret { error ! ( " " err ) ; } false } MiscMessage :: Normal => { if self . exchange == super :: mxc :: EXCHANGE_NAME && self . url . as_str ( ) == super :: mxc :: SPOT_WEBSOCKET_URL { // special logic for MXC Spot match txt . strip_prefix ( " " ) { Some ( msg ) => ( self . on_msg . lock ( ) . unwrap ( ) ) ( msg . to_string ( ) ) , None => error ! ( " " txt self exchange ) , } } else { ( self . on_msg . lock ( ) . unwrap ( ) ) ( txt . to_string ( ) ) ; } true } } }
Handle a text msg from Message::Text or Message::Binary
Returns true if gets a normal message, otherwise false
Handle a text msg from Message :: Text or Message :: Binary Returns true if gets a normal message otherwise false
&self
txt
&str