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