aboutsummaryrefslogtreecommitdiff
path: root/client-native-lib
diff options
context:
space:
mode:
authormetamuffin <metamuffin@disroot.org>2022-09-14 20:23:40 +0200
committermetamuffin <metamuffin@disroot.org>2022-09-14 20:23:40 +0200
commit9b6b92d0cec58c3054c389f73fc86b96b79c17d1 (patch)
tree8077c8e6fb00179ca31cd2e6822bf0315419bac7 /client-native-lib
parentc752fe962df841b0cb811b09f155568735e7380c (diff)
downloadkeks-meet-9b6b92d0cec58c3054c389f73fc86b96b79c17d1.tar
keks-meet-9b6b92d0cec58c3054c389f73fc86b96b79c17d1.tar.bz2
keks-meet-9b6b92d0cec58c3054c389f73fc86b96b79c17d1.tar.zst
extract lib
Diffstat (limited to 'client-native-lib')
-rw-r--r--client-native-lib/Cargo.toml2
-rw-r--r--client-native-lib/src/lib.rs (renamed from client-native-lib/src/main.rs)41
-rw-r--r--client-native-lib/src/peer.rs7
-rw-r--r--client-native-lib/src/state.rs6
4 files changed, 14 insertions, 42 deletions
diff --git a/client-native-lib/Cargo.toml b/client-native-lib/Cargo.toml
index 0fa740b..15a1084 100644
--- a/client-native-lib/Cargo.toml
+++ b/client-native-lib/Cargo.toml
@@ -14,8 +14,6 @@ url = "2.3.1"
serde = { version = "1.0.144", features = ["derive"] }
serde_json = "*"
-clap = { version = "3.2.21", features = ["derive"] }
-env_logger = "0.8"
log = "0.4"
fastpbkdf2 = "0.1.0"
diff --git a/client-native-lib/src/main.rs b/client-native-lib/src/lib.rs
index f2b79e2..118d962 100644
--- a/client-native-lib/src/main.rs
+++ b/client-native-lib/src/lib.rs
@@ -1,8 +1,7 @@
#![feature(async_closure)]
#![feature(box_syntax)]
-use clap::{Parser, Subcommand};
-use log::{debug, error};
+use log::debug;
use signaling::signaling_connect;
use state::State;
use std::sync::Arc;
@@ -20,35 +19,15 @@ pub mod protocol;
pub mod signaling;
pub mod state;
-fn main() {
- env_logger::init_from_env("LOG");
- tokio::runtime::Builder::new_multi_thread()
- .enable_all()
- .build()
- .unwrap()
- .block_on(run())
+pub struct Config {
+ pub signaling_host: String,
+ pub secret: String,
}
-#[derive(Parser)]
-pub struct Args {
- #[clap(long, default_value = "meet.metamuffin.org")]
- signaling_host: String,
- #[clap(short, long)]
- secret: String,
- #[clap(subcommand)]
- action: Action,
-}
-#[derive(Subcommand)]
-pub enum Action {
- Send {},
- Receive {},
-}
+pub async fn connect(config: Config) -> Arc<State> {
+ let (sender, mut recv) = signaling_connect(&config.signaling_host, &config.secret).await;
-async fn run() {
- let args = Args::parse();
- let (sender, mut recv) = signaling_connect(&args.signaling_host, &args.secret).await;
-
- let key = crypto::Key::derive(&args.secret);
+ let key = crypto::Key::derive(&config.secret);
let mut media_engine = MediaEngine::default();
media_engine.register_default_codecs().unwrap();
@@ -65,7 +44,7 @@ async fn run() {
api,
my_id: RwLock::new(None),
sender,
- args,
+ config,
});
{
@@ -79,7 +58,5 @@ async fn run() {
}
});
}
-
- tokio::signal::ctrl_c().await.unwrap();
- error!("interrupt received, exiting");
+ state
}
diff --git a/client-native-lib/src/peer.rs b/client-native-lib/src/peer.rs
index 8402fc6..64eb641 100644
--- a/client-native-lib/src/peer.rs
+++ b/client-native-lib/src/peer.rs
@@ -12,7 +12,6 @@ use webrtc::{
use crate::{
protocol::{self, RTCSessionDescriptionInit, RelayMessage},
state::State,
- Action,
};
pub struct Peer {
@@ -83,9 +82,9 @@ impl Peer {
.await;
}
- if let Action::Send { .. } = &peer.state.args.action {
- peer.start_transfer().await
- }
+ // if let Action::Send { .. } = &peer.state.args.action {
+ // peer.start_transfer().await
+ // }
peer
}
diff --git a/client-native-lib/src/state.rs b/client-native-lib/src/state.rs
index baea90a..57c4b29 100644
--- a/client-native-lib/src/state.rs
+++ b/client-native-lib/src/state.rs
@@ -7,12 +7,11 @@ use webrtc::api::API;
use crate::{
crypto::Key,
peer::Peer,
- protocol::{self, ClientboundPacket, RelayMessage, RelayMessageWrapper, ServerboundPacket},
- Action, Args,
+ protocol::{self, ClientboundPacket, RelayMessage, RelayMessageWrapper, ServerboundPacket}, Config,
};
pub struct State {
- pub args: Args,
+ pub config: Config,
pub api: API,
pub key: Key,
pub my_id: RwLock<Option<usize>>,
@@ -40,7 +39,6 @@ impl State {
.write()
.await
.insert(id, Peer::create(self.clone(), id).await);
- if let Action::Send { .. } = &self.args.action {}
}
}
protocol::ClientboundPacket::ClientLeave { id: _ } => {}