p2p/connection/
p2p_connection_service.rs

1use std::collections::BTreeSet;
2
3use crate::{identity::PublicKey, webrtc, PeerId};
4
5use super::outgoing::P2pConnectionOutgoingInitOpts;
6
7pub trait P2pConnectionService: redux::Service {
8    fn connections(&self) -> BTreeSet<PeerId>;
9
10    fn random_pick(
11        &mut self,
12        list: &[P2pConnectionOutgoingInitOpts],
13    ) -> Option<P2pConnectionOutgoingInitOpts>;
14
15    /// Initiates an outgoing connection and creates an offer sdp,
16    /// which will be received in the state machine as an event.
17    fn outgoing_init(&mut self, opts: P2pConnectionOutgoingInitOpts);
18
19    /// Initiates an incoming connection and creates an answer sdp,
20    /// which will be received in the state machine as an event.
21    fn incoming_init(&mut self, peer_id: PeerId, offer: webrtc::Offer);
22
23    fn set_answer(&mut self, peer_id: PeerId, answer: webrtc::Answer);
24
25    fn http_signaling_request(&mut self, url: String, offer: webrtc::Offer);
26
27    fn auth_encrypt_and_send(
28        &mut self,
29        peer_id: PeerId,
30        other_pub_key: &PublicKey,
31        auth: webrtc::ConnectionAuth,
32    );
33
34    fn auth_decrypt(
35        &mut self,
36        other_pub_key: &PublicKey,
37        auth: webrtc::ConnectionAuthEncrypted,
38    ) -> Option<webrtc::ConnectionAuth>;
39}