use std::{net::SocketAddr, sync::Arc};
use crate::{app::TaskBody, vo_factory::input_vo::InputBufVO};
use super::{
input_dto::IHandlerCombinedTrait,
router_handler::{HandlerData, IHandlerData, IHandlerMethod},
AsyncFunc, ClientsStructType,
};
pub(crate) struct MsgSelect {
pub(crate) addr: SocketAddr,
pub(crate) input_buf_vo: InputBufVO,
}
impl MsgSelect {
pub(crate) fn new(addr: SocketAddr, input_buf_vo: InputBufVO) -> Self {
Self { addr, input_buf_vo }
}
}
impl IHandlerCombinedTrait for MsgSelect {
async fn execute(
&mut self,
clients: ClientsStructType,
handler_method: Arc<AsyncFunc>,
thread_pool: TaskBody,
) {
self.handler(handler_method, thread_pool, clients).await;
}
}
impl IHandlerData for MsgSelect {
fn get_data(&self) -> super::router_handler::HandlerData {
HandlerData::new_without_data()
}
}
impl IHandlerMethod for MsgSelect {
async fn handler(
&mut self,
handler_method: Arc<AsyncFunc>,
thread_pool: TaskBody,
clients: ClientsStructType,
) {
let task_body = (handler_method.clone(), self.input_buf_vo.clone(), clients);
thread_pool.send(task_body).await;
}
}