use std::{net::SocketAddr, sync::Arc};
use crate::{app::TaskBody, handler::HandlerContext, 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) handler_context: HandlerContext,
}
impl MsgSelect {
pub(crate) fn new(addr: SocketAddr, handler_context: HandlerContext) -> Self {
Self {
addr,
handler_context,
}
}
}
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.handler_context.clone(),
clients,
);
thread_pool.send(task_body).await;
}
}