init
This commit is contained in:
@@ -0,0 +1,35 @@
|
||||
use crate::models::{channel, user};
|
||||
use axum::extract::ws::Message;
|
||||
use rustrtc::peer_connection::PeerConnection;
|
||||
use std::sync::Arc;
|
||||
use tokio::sync::mpsc::UnboundedSender;
|
||||
|
||||
/// Client connecté à un canal RTC.
|
||||
#[derive(Clone)]
|
||||
pub struct RtcClient {
|
||||
pub user: user::Model,
|
||||
pub channel: channel::Model,
|
||||
pub peer_connection: Arc<PeerConnection>,
|
||||
pub websocket_sender: UnboundedSender<Message>,
|
||||
}
|
||||
|
||||
impl RtcClient {
|
||||
pub fn new(
|
||||
user: user::Model,
|
||||
channel: channel::Model,
|
||||
peer_connection: Arc<PeerConnection>,
|
||||
websocket_sender: UnboundedSender<Message>,
|
||||
) -> Self {
|
||||
Self {
|
||||
user,
|
||||
channel,
|
||||
peer_connection,
|
||||
websocket_sender,
|
||||
}
|
||||
}
|
||||
|
||||
/// Ferme proprement la connexion WebRTC.
|
||||
pub fn close(&self) {
|
||||
self.peer_connection.close();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user