pub fn write_message(
        &mut self,
        message_in: String,
        stream: &mut BufStream<TcpStream>,
    ) -> Result<(), String> {
        let mut message = message_in.clone();
        if !message.ends_with("\n") {
            message += "\n";
        }
        match stream.write(message.as_bytes()) {
            Ok(_) => match stream.flush() {
                Ok(_) => {}
                Err(e) => {
                    error!("{} - Connection Error 2: {}", self.id, e);
                    return Err(format!("{}", e));
                }
            },
            Err(e) => {
                error!("{} - Connection Error 2a: {}", self.id, e);
                return Err(format!("{}", e));
            }
        }
        return Ok(());
    }
/// Write a message to the stream and flush
Write a message to the stream and flush
Write a message to the stream and flush
pub fn write_message(
        &mut self,
        message_in: String,
        stream: &mut BufStream<TcpStream>,
    ) -> Result<(), String> {
        let mut message = message_in.clone();
        if !message.ends_with("\n") {
            message += "\n";
        }
        match stream.write(message.as_bytes()) {
            Ok(_) => match stream.flush() {
                Ok(_) => {}
                Err(e) => {
                    error!("{} - Connection Error 2: {}", self.id, e);
                    return Err(format!("{}", e));
                }
            },
            Err(e) => {
                error!("{} - Connection Error 2a: {}", self.id, e);
                return Err(format!("{}", e));
            }
        }
        return Ok(());
    }
pub fn write_message ( & mut self , message_in : String , stream : & mut BufStream < TcpStream > , ) -> Result < ( ) , String > { let mut message = message_in . clone ( ) ; if ! message . ends_with ( " \n " ) { message += " \n " ; } match stream . write ( message . as_bytes ( ) ) { Ok ( _ ) => match stream . flush ( ) { Ok ( _ ) => { } Err ( e ) => { error ! ( " " self id e ) ; return Err ( format ! ( " " e ) ) ; } } , Err ( e ) => { error ! ( " " self id e ) ; return Err ( format ! ( " " e ) ) ; } } return Ok ( ( ) ) ; }
Write a message to the stream and flush
Write a message to the stream and flush
&mut self
message_in
String
stream
&mut BufStream<TcpStream>