chore: converted to log commands
This commit is contained in:
parent
2b8d8e8dfd
commit
1e3a3c19db
1 changed files with 8 additions and 14 deletions
22
src/main.rs
22
src/main.rs
|
@ -113,14 +113,12 @@ fn main() {
|
||||||
"Socket listening on: {}",
|
"Socket listening on: {}",
|
||||||
tcp_listener.local_addr().unwrap()
|
tcp_listener.local_addr().unwrap()
|
||||||
);
|
);
|
||||||
println!("Listening on {}", tcp_listener.local_addr().unwrap());
|
|
||||||
|
|
||||||
loop {
|
loop {
|
||||||
if let Ok((stream, addr)) = tcp_listener.accept() {
|
if let Ok((stream, addr)) = tcp_listener.accept() {
|
||||||
stream.set_nonblocking(true).unwrap();
|
stream.set_nonblocking(true).unwrap();
|
||||||
|
|
||||||
info!("New socket connected from: {}", addr);
|
info!("New socket connected from: {}", addr);
|
||||||
println!("New socket connected from: {}", addr);
|
|
||||||
|
|
||||||
match accept(stream) {
|
match accept(stream) {
|
||||||
Ok(sck) => sockets.push(sck),
|
Ok(sck) => sockets.push(sck),
|
||||||
|
@ -139,7 +137,7 @@ fn main() {
|
||||||
if mess.is_text() {
|
if mess.is_text() {
|
||||||
match server_handling::handle_request(mess.into_text().unwrap()) {
|
match server_handling::handle_request(mess.into_text().unwrap()) {
|
||||||
Err(error) => {
|
Err(error) => {
|
||||||
println!("There was an error decoding the message: {:?}", error)
|
error!("There was an error decoding the message: {:?}", error)
|
||||||
}
|
}
|
||||||
Ok(req) => handle_uirequest(
|
Ok(req) => handle_uirequest(
|
||||||
req,
|
req,
|
||||||
|
@ -154,7 +152,7 @@ fn main() {
|
||||||
}
|
}
|
||||||
Err(error) => match error {
|
Err(error) => match error {
|
||||||
tungstenite::Error::ConnectionClosed => {
|
tungstenite::Error::ConnectionClosed => {
|
||||||
println!("dropping socket");
|
info!("dropping socket: {}", i);
|
||||||
let tmp = sockets.remove(i);
|
let tmp = sockets.remove(i);
|
||||||
drop(tmp);
|
drop(tmp);
|
||||||
}
|
}
|
||||||
|
@ -169,14 +167,11 @@ fn main() {
|
||||||
{
|
{
|
||||||
sockets.remove(i);
|
sockets.remove(i);
|
||||||
} else {
|
} else {
|
||||||
println!("There was an IO error: {}", error.to_string());
|
error!("There was an IO error: {}", error.to_string());
|
||||||
}
|
}
|
||||||
|
|
||||||
//panic!();
|
|
||||||
//continue;
|
|
||||||
}
|
}
|
||||||
_ => {
|
_ => {
|
||||||
println!("A socket errored: {}", error.to_string());
|
warn!("A socket errored: {}", error.to_string());
|
||||||
sockets.remove(i);
|
sockets.remove(i);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
@ -203,7 +198,8 @@ fn handle_uirequest(
|
||||||
}
|
}
|
||||||
UIRequest::Skip(skip_direction) => todo!(),
|
UIRequest::Skip(skip_direction) => todo!(),
|
||||||
UIRequest::Search(request) => {
|
UIRequest::Search(request) => {
|
||||||
println!("got a: {:?}", request);
|
// TODO: switch this to a debug
|
||||||
|
info!("got a: {:?}", request);
|
||||||
let items = dbo
|
let items = dbo
|
||||||
.get(&DatabaseRequest {
|
.get(&DatabaseRequest {
|
||||||
search_type: db_operations::SearchType::Like,
|
search_type: db_operations::SearchType::Like,
|
||||||
|
@ -217,8 +213,6 @@ fn handle_uirequest(
|
||||||
write_to_socket(socket, "Here are the results:".to_string(), items).unwrap();
|
write_to_socket(socket, "Here are the results:".to_string(), items).unwrap();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//println!("got from db: {:?}", items);
|
|
||||||
}
|
}
|
||||||
UIRequest::SwitchTo(partial_tag) => {
|
UIRequest::SwitchTo(partial_tag) => {
|
||||||
let items = dbo
|
let items = dbo
|
||||||
|
@ -242,7 +236,7 @@ fn handle_uirequest(
|
||||||
)
|
)
|
||||||
.unwrap();
|
.unwrap();
|
||||||
} else {
|
} else {
|
||||||
println!(
|
info!(
|
||||||
"Switching song to: '{}'",
|
"Switching song to: '{}'",
|
||||||
items.get(0).unwrap().title.clone()
|
items.get(0).unwrap().title.clone()
|
||||||
);
|
);
|
||||||
|
@ -250,7 +244,7 @@ fn handle_uirequest(
|
||||||
music_player
|
music_player
|
||||||
.change_now_playing(items.get(0).unwrap().clone())
|
.change_now_playing(items.get(0).unwrap().clone())
|
||||||
.unwrap();
|
.unwrap();
|
||||||
println!("{}", items.get(0).unwrap().path.clone());
|
info!("{}", items.get(0).unwrap().path.clone());
|
||||||
|
|
||||||
write_to_socket(socket, "Switching now playing".to_string(), items)
|
write_to_socket(socket, "Switching now playing".to_string(), items)
|
||||||
.unwrap();
|
.unwrap();
|
||||||
|
|
Loading…
Reference in a new issue