mirror of
https://github.com/Noratrieb/terminal-chat.git
synced 2026-01-14 16:35:10 +01:00
better prints
This commit is contained in:
parent
d500a9c2ad
commit
fccb89b725
2 changed files with 5 additions and 5 deletions
|
|
@ -11,7 +11,7 @@ pub fn listen() -> StreamResult {
|
|||
println!("Listening on {}:8080", local_ipaddress::get().unwrap());
|
||||
let listener = TcpListener::bind(("127.0.0.1", 8080))?;
|
||||
let stream = listener.incoming().next().unwrap()?;
|
||||
println!("Connected. Waiting for response stream...");
|
||||
println!("Connected.");
|
||||
println!("other adress: {}", stream.peer_addr()?.ip());
|
||||
|
||||
Ok(stream)
|
||||
|
|
@ -24,6 +24,7 @@ pub fn connect(address: String, port: String) -> StreamResult {
|
|||
let stream = TcpStream::connect((&*address, port))?;
|
||||
|
||||
println!("Connected.");
|
||||
println!("other adress: {}", stream.peer_addr()?.ip());
|
||||
|
||||
Ok(stream)
|
||||
}
|
||||
|
|
@ -44,6 +45,7 @@ pub fn network_thread(mut stream: TcpStream, rx: Receiver<String>) {
|
|||
}
|
||||
|
||||
pub fn ui_thread(sx: Sender<String>) {
|
||||
println!("You can now write messages to your peer!");
|
||||
loop {
|
||||
let input = input();
|
||||
sx.send(input).expect("could not send value");
|
||||
|
|
|
|||
|
|
@ -16,9 +16,9 @@ fn main() {
|
|||
Version 0.1"
|
||||
);
|
||||
|
||||
println!("Do you want to listen(l) or connect(c) to a listener?");
|
||||
println!("Do you want to (l)isten or (c)onnect to a listener?");
|
||||
|
||||
let result = if input().contains("l") {
|
||||
let result = if input() == "l" {
|
||||
listen()
|
||||
} else {
|
||||
println!("Address: (empty for default)");
|
||||
|
|
@ -36,8 +36,6 @@ Version 0.1"
|
|||
|
||||
match result {
|
||||
Ok(s) => {
|
||||
println!("Successful connection established.");
|
||||
|
||||
let (sx, rx): (Sender<String>, Receiver<String>) = mpsc::channel();
|
||||
|
||||
let net = thread::spawn(move || {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue