pub struct HandlerChain {
message_handlers: Vec<Box<RefCell<dyn IMessageHandler>>>,
}
Expand description
Represents a list of handlers that all implement the IMessageHandler trait. This list can be dynamically updated and each element in the list is passed messages for processing.
Fields§
§message_handlers: Vec<Box<RefCell<dyn IMessageHandler>>>
The list of message handlers.
Implementations§
source§impl HandlerChain
impl HandlerChain
sourcepub fn new() -> HandlerChain
pub fn new() -> HandlerChain
sourcepub fn add_handler(&mut self, handler: impl IMessageHandler + 'static)
pub fn add_handler(&mut self, handler: impl IMessageHandler + 'static)
Add the given instance of the IMessageHandler interface to end of the list of handlers.
Normally this would guard against adding the same window twice, but this HandlerChain takes ownership of the window and therefore the same window can never be added twice to this HandlerChain.
sourcepub fn remove_handler(&mut self, handler_id: i32)
pub fn remove_handler(&mut self, handler_id: i32)
Remove an instance of the IMessageHandler interface from the list.
If the message handler is not in the list, the request to remove is ignored.
sourcepub fn send_message(&mut self, message: &Message)
pub fn send_message(&mut self, message: &Message)
Send a message to each of the handlers in the list.
Parameters
-
message
The Message object to send to each handler.