summaryrefslogtreecommitdiff
path: root/client-native-lib/src/lib.rs
diff options
context:
space:
mode:
Diffstat (limited to 'client-native-lib/src/lib.rs')
-rw-r--r--client-native-lib/src/lib.rs39
1 files changed, 22 insertions, 17 deletions
diff --git a/client-native-lib/src/lib.rs b/client-native-lib/src/lib.rs
index 6ffbee3..bb88b9f 100644
--- a/client-native-lib/src/lib.rs
+++ b/client-native-lib/src/lib.rs
@@ -7,6 +7,11 @@
#![feature(box_syntax)]
#![feature(async_fn_in_trait)]
+use std::{pin::Pin, sync::Arc};
+
+use futures_util::Future;
+use peer::Peer;
+use protocol::ProvideInfo;
use state::State;
use tokio::sync::RwLock;
use webrtc::{
@@ -27,25 +32,10 @@ pub use webrtc;
pub struct Config {
pub signaling_uri: String,
pub secret: String,
+ pub username: String,
}
-impl State {
- pub async fn new(config: Config) -> Self {
- let conn = signaling::SignalingConnection::new(&config.signaling_uri, &config.secret).await;
- let key = crypto::Key::derive(&config.secret);
-
- Self {
- api: build_api(),
- my_id: RwLock::new(None),
- peers: Default::default(),
- config,
- conn,
- key,
- }
- }
-}
-
-fn build_api() -> webrtc::api::API {
+pub(crate) fn build_api() -> webrtc::api::API {
let mut media_engine = MediaEngine::default();
media_engine.register_default_codecs().unwrap();
let mut registry = Registry::new();
@@ -55,3 +45,18 @@ fn build_api() -> webrtc::api::API {
.with_interceptor_registry(registry)
.build()
}
+
+pub trait LocalResource: Send + Sync + 'static {
+ fn info(&self) -> ProvideInfo;
+ fn on_request(&self, peer: Arc<Peer>) -> Box<dyn Future<Output = ()>>;
+}
+
+pub trait EventHandler: Send + Sync + 'static {
+ fn remote_resource_added(
+ &self,
+ peer: &Peer,
+ info: ProvideInfo,
+ ) -> Pin<Box<dyn Future<Output = ()>>>;
+ fn remote_resource_removed(&self, peer: &Peer, id: String)
+ -> Pin<Box<dyn Future<Output = ()>>>;
+}