webhook test for Discord (also still errors for macros)
This commit is contained in:
parent
288764df1e
commit
d085789fab
@ -1,20 +1,10 @@
|
||||
use std;
|
||||
use std::io::*;
|
||||
use std::net::TcpStream;
|
||||
use std::thread;
|
||||
|
||||
static leave_msg: &str = "BYE";
|
||||
|
||||
// macro_rules! send {
|
||||
// ($line:expr) => ({
|
||||
// try!(writeln!(writer, "{}", $line));
|
||||
// try!(writer.flush());
|
||||
// })
|
||||
// }
|
||||
|
||||
fn send(writer: BufWriter<&TcpStream>,text: &str) {
|
||||
|
||||
}
|
||||
|
||||
fn get_entry() -> String {
|
||||
let mut buf = String::new();
|
||||
|
||||
@ -23,19 +13,25 @@ fn get_entry() -> String {
|
||||
}
|
||||
|
||||
fn write_to_server(stream: TcpStream) {
|
||||
|
||||
let mut writer = BufWriter::new(&stream);
|
||||
|
||||
macro_rules! send {
|
||||
($line:expr) => ({
|
||||
try!(writeln!(writer, "{}", $line));
|
||||
try!(writer.flush());
|
||||
})
|
||||
}
|
||||
|
||||
loop {
|
||||
match &*get_entry() {
|
||||
"/quit" => {
|
||||
println!("Disconnecting...");
|
||||
|
||||
send!("BYE");
|
||||
println!("Disconnected!");
|
||||
return ();
|
||||
}
|
||||
line => {
|
||||
send(BufWriter::new(&stream), line);
|
||||
send!(line);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -56,14 +52,14 @@ fn exchange_with_server(stream: TcpStream) {
|
||||
match reader.read_line(&mut line) {
|
||||
Ok(len) => {
|
||||
if len == 0 {
|
||||
// Reader is at EOF.
|
||||
return Err(Error::new(ErrorKind::Other, "unexpected EOF"));
|
||||
// Reader is at EOF. Could use ErrorKind::UnexpectedEOF, but still unstable.
|
||||
let ret = std::io::Error::new(std::io::ErrorKind::Other, "test");
|
||||
return Err(ret): std::result::Result<&str, std::io::Error>;
|
||||
// return Err(Error::new(ErrorKind::Other, "unexpected EOF"));
|
||||
}
|
||||
line.pop();
|
||||
}
|
||||
Err(e) => {
|
||||
return Err(e);
|
||||
}
|
||||
Err(e) => { return Err(e); }
|
||||
};
|
||||
line
|
||||
})
|
||||
@ -73,13 +69,11 @@ fn exchange_with_server(stream: TcpStream) {
|
||||
write_to_server(stream.try_clone().unwrap());
|
||||
});
|
||||
|
||||
match(|| {
|
||||
loop {
|
||||
let input = receive!();
|
||||
println!("{}", input);
|
||||
}
|
||||
|
||||
})() {
|
||||
match (|| loop {
|
||||
let input = receive!();
|
||||
println!("{}", input);
|
||||
})()
|
||||
{
|
||||
Ok(_) => {
|
||||
println!("Left?");
|
||||
}
|
||||
|
@ -1,3 +1,5 @@
|
||||
#![feature(type_ascription)]
|
||||
|
||||
use std::env;
|
||||
|
||||
pub mod client;
|
||||
|
Loading…
Reference in New Issue
Block a user