From 1d23f7b835ec6714cda248981e642c48fc551dce Mon Sep 17 00:00:00 2001 From: metamuffin Date: Fri, 7 Oct 2022 23:25:39 +0200 Subject: transport works. --- client-native-lib/src/lib.rs | 23 ++++++++++++++--------- 1 file changed, 14 insertions(+), 9 deletions(-) (limited to 'client-native-lib/src/lib.rs') diff --git a/client-native-lib/src/lib.rs b/client-native-lib/src/lib.rs index 27c0595..7a0d0d0 100644 --- a/client-native-lib/src/lib.rs +++ b/client-native-lib/src/lib.rs @@ -10,9 +10,9 @@ use std::{pin::Pin, sync::Arc}; use futures_util::Future; -use peer::Peer; -use protocol::ProvideInfo; use instance::Instance; +use peer::{Peer, TransportChannel}; +use protocol::ProvideInfo; use tokio::sync::RwLock; use webrtc::{ api::{ @@ -22,10 +22,10 @@ use webrtc::{ }; pub mod crypto; +pub mod instance; pub mod peer; pub mod protocol; pub mod signaling; -pub mod instance; pub use webrtc; @@ -46,17 +46,22 @@ pub(crate) fn build_api() -> webrtc::api::API { .build() } +pub type DynFut = Pin + Send>>; + pub trait LocalResource: Send + Sync + 'static { fn info(&self) -> ProvideInfo; - fn on_request(&self, peer: Arc) -> Box>; + fn on_request(&self, peer: Arc) -> DynFut<()>; } pub trait EventHandler: Send + Sync + 'static { - fn remote_resource_added( + fn peer_join(&self, peer: Arc) -> DynFut<()>; + fn peer_leave(&self, peer: Arc) -> DynFut<()>; + fn resource_added(&self, peer: Arc, info: ProvideInfo) -> DynFut<()>; + fn resource_removed(&self, peer: Arc, id: String) -> DynFut<()>; + fn resource_connected( &self, peer: Arc, - info: ProvideInfo, - ) -> Pin>>; - fn remote_resource_removed(&self, peer: Arc, id: String) - -> Pin>>; + resource: &ProvideInfo, + channel: TransportChannel, + ) -> DynFut<()>; } -- cgit v1.2.3-70-g09d2