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

7
musicdb-lib/Cargo.toml Executable file → Normal file
View File

@@ -6,8 +6,11 @@ edition = "2021"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
[dependencies]
awedio = "0.2.0"
awedio = { version = "0.2.0", optional = true }
base64 = "0.21.2"
rand = "0.8.5"
rc-u8-reader = "2.0.16"
tokio = "1.29.1"
tokio = { version = "1.29.1", features = ["sync"] }
[features]
playback = ["awedio"]

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>,