use std::{net::SocketAddr, sync::Arc};
use crate::{
app::{AsyncFunc, ClientsStructType, TaskBody},
handler::HandlerContext,
};
use super::{input_dto::IHandlerCombinedTrait, router_handler::IHandlerMethod};
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 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.push(task_body);
}
}