use std::{collections::BTreeSet, fmt::Debug};
use opentalk_roomserver_signaling::signaling_module::InternalCommand;
use opentalk_roomserver_types::livekit_proxy::{
LiveKitProxyRequest, PreparedSocket, websocket::LiveKitSocket,
};
use opentalk_types_signaling::ParticipantId;
use tokio::sync::oneshot;
use url::Url;
use crate::MicrophoneRestrictionState;
#[derive(Debug)]
pub enum LiveKitInternal {
Mute {
sender: Option<ParticipantId>,
participants: BTreeSet<ParticipantId>,
return_channel: oneshot::Sender<ParticipantsMuted>,
},
UpdateMicrophoneRestrictions {
sender: ParticipantId,
new_state: MicrophoneRestrictionState,
return_channel:
oneshot::Sender<Result<MicrophoneRestrictionState, MicrophoneRestrictionError>>,
},
ConnectUpstreamSocket {
websocket_request: Box<LiveKitProxyRequest>,
return_channel: oneshot::Sender<Option<PreparedSocket>>,
},
ConnectDownstreamSocket {
websocket_request: Box<LiveKitProxyRequest>,
upstream_socket: Box<PreparedSocket>,
downstream_socket: Box<dyn LiveKitSocket>,
return_channel: oneshot::Sender<()>,
},
GetLivekitServiceUrl {
return_channel: oneshot::Sender<Url>,
},
}
#[derive(Debug)]
pub enum MicrophoneRestrictionErrorKind {
ConflictingTask,
LivekitUnavailable,
}
#[derive(Debug)]
pub struct MicrophoneRestrictionError {
pub sender: ParticipantId,
pub error: MicrophoneRestrictionErrorKind,
}
#[derive(Debug)]
pub struct ParticipantsMuted {
pub sender: Option<ParticipantId>,
pub participants: BTreeSet<ParticipantId>,
}
impl InternalCommand for LiveKitInternal {}