pub use cnctd_protocol::message::{Message, SocketMessage, UserMessage, UserSocketMessage};
use crate::socket::connection::Connections;
#[async_trait::async_trait]
pub trait Push {
async fn broadcast(&self) -> anyhow::Result<()>;
async fn to_user(&self, user_id: &str, exclude_connection_id: Option<String>) -> anyhow::Result<()>;
}
#[async_trait::async_trait]
impl Push for Message {
async fn broadcast(&self) -> anyhow::Result<()> {
Connections::global()?.broadcast(self).await
}
async fn to_user(&self, user_id: &str, exclude_connection_id: Option<String>) -> anyhow::Result<()> {
Connections::global()?.message_user(user_id, self, exclude_connection_id).await
}
}