This commit is contained in:
Mark
2023-12-27 15:39:53 +01:00
parent 168f51a5fc
commit 8c434743f8
17 changed files with 1621 additions and 121 deletions

View File

@@ -1,4 +1,5 @@
pub mod data;
pub mod load;
#[cfg(feature = "playback")]
pub mod player;
pub mod server;

View File

@@ -1,11 +1,8 @@
pub mod get;
use std::{
io::{BufRead, BufReader, Read, Write},
net::{SocketAddr, TcpListener},
io::{Read, Write},
sync::{mpsc, Arc, Mutex},
thread,
time::Duration,
};
use crate::{
@@ -18,8 +15,15 @@ use crate::{
AlbumId, ArtistId, SongId,
},
load::ToFromBytes,
player::Player,
server::get::handle_one_connection_as_get,
};
#[cfg(feature = "playback")]
use crate::{player::Player, server::get::handle_one_connection_as_get};
#[cfg(feature = "playback")]
use std::{
io::{BufRead, BufReader},
net::{SocketAddr, TcpListener},
thread,
time::Duration,
};
#[derive(Clone, Debug)]
@@ -84,6 +88,7 @@ impl Command {
/// a) initialize new connections using db.init_connection() to synchronize the new client
/// b) handle the decoding of messages using Command::from_bytes()
/// c) re-encode all received messages using Command::to_bytes_vec(), send them to the db, and send them to all your clients.
#[cfg(feature = "playback")]
pub fn run_server(
database: Arc<Mutex<Database>>,
addr_tcp: Option<SocketAddr>,