pub struct Peer<Msg>where
Msg: UserMsgPayload + 'static,{ /* private fields */ }Expand description
User-facing handle to a mesh peer running in the browser.
Implementations§
Source§impl<Msg> Peer<Msg>where
Msg: UserMsgPayload + 'static,
impl<Msg> Peer<Msg>where
Msg: UserMsgPayload + 'static,
pub fn new() -> Self
pub fn with_ice_servers(ice_servers: Vec<IceServerConfig>) -> Self
pub fn with_storage(ice_servers: Vec<IceServerConfig>, storage: Storage) -> Self
pub fn my_id(&self) -> PeerID
pub fn subscribe(&self, subscription: Event<Msg>) -> u64
pub fn unsubscribe(&self, id: u64) -> bool
pub async fn start(&self) -> Result<String>
pub async fn receive_offer(&self, offer: &str) -> Result<String>
pub async fn receive_answer(&self, answer: &str) -> Result<()>
pub fn send(&self, peer_id: PeerID, data: Msg)
pub fn broadcast(&self, data: Msg)
pub fn leave(&self)
pub fn is_connected(&self, peer_id: PeerID) -> bool
pub fn connected_peers(&self) -> HashSet<String>
Trait Implementations§
Source§impl<Msg> Default for Peer<Msg>where
Msg: UserMsgPayload + 'static,
impl<Msg> Default for Peer<Msg>where
Msg: UserMsgPayload + 'static,
Auto Trait Implementations§
impl<Msg> Freeze for Peer<Msg>
impl<Msg> !RefUnwindSafe for Peer<Msg>
impl<Msg> !Send for Peer<Msg>
impl<Msg> !Sync for Peer<Msg>
impl<Msg> Unpin for Peer<Msg>
impl<Msg> UnsafeUnpin for Peer<Msg>
impl<Msg> !UnwindSafe for Peer<Msg>
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more