use crate::controller::{IProxy, ___impl_IProxy_call};
use crate::services::IProxyService;
use crate::static_def::PROXY;
use anyhow::Result;
use netxserver::prelude::*;
#[derive(Default)]
pub struct BroadcastService;
impl BroadcastService {
#[inline]
pub async fn broadcast_to_account_id(&self, account_id: i32, data: &[u8]) -> Result<()> {
for netx_token in PROXY.get_all_token().await? {
let proxy = impl_ref!(netx_token=>IProxy);
proxy.broadcast_to_account_id(account_id, data).await;
}
Ok(())
}
#[inline]
pub async fn broadcast_to_all_users(&self, data: &[u8]) -> Result<()> {
for netx_token in PROXY.get_all_token().await? {
let proxy = impl_ref!(netx_token=>IProxy);
proxy.broadcast_to_all_users(data).await;
}
Ok(())
}
#[inline]
pub async fn broadcast_to_server_id(&self, data: &[u8]) -> Result<()> {
for netx_token in PROXY.get_all_token().await? {
let proxy = impl_ref!(netx_token=>IProxy);
proxy.broadcast_to_server_id(0, data).await;
}
Ok(())
}
#[inline]
pub async fn broadcast_to_server_id_and_account_id(
&self,
account_id: i32,
data: &[u8],
) -> Result<()> {
for netx_token in PROXY.get_all_token().await? {
let proxy = impl_ref!(netx_token=>IProxy);
proxy
.broadcast_to_server_id_and_account_id(0, account_id, data)
.await;
}
Ok(())
}
}