This commit is contained in:
2026-09-19 21:34:06 +02:00
parent 8d48b1617b
commit 8297111060
8 changed files with 97 additions and 23 deletions
+35
View File
@@ -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();
}
}