use crate::Channel;
use crate::{ChannelMessage, SendMessage};
use async_trait::async_trait;
use std::sync::Arc;
pub struct VoiceChannel;
#[async_trait]
impl Channel for VoiceChannel {
async fn send(&self, _message: &SendMessage) -> anyhow::Result<()> {
Ok(())
}
async fn listen(&self, _tx: tokio::sync::mpsc::Sender<ChannelMessage>) -> anyhow::Result<()> {
Ok(())
}
fn name(&self) -> &'static str {
"voice"
}
fn as_any(&self) -> &dyn std::any::Any {
self
}
}
pub fn register_global() {
let channel: Arc<dyn Channel> = Arc::new(VoiceChannel);
crate::channel_registry().register(channel);
}
#[cfg(test)]
mod tests {
use super::*;
use crate::{CHANNEL_REGISTRY, ChannelRegistry, channel_registry};
#[test]
fn test_voice_channel_registration() {
CHANNEL_REGISTRY.get_or_init(ChannelRegistry::default);
register_global();
let found = channel_registry().get("voice");
assert!(
found.is_some(),
"VoiceChannel should be findable by 'voice' name"
);
}
}