-
-
Notifications
You must be signed in to change notification settings - Fork 4
Own opcode handlers
Since version v11.2.0
, it has been possible to pass custom opcode processors into Tentacli. This can be done through custom features.
pub trait Feature: Send {
fn set_broadcast_channel(
&mut self,
_sender: BroadcastSender<HandlerOutput>,
_receiver: BroadcastReceiver<HandlerOutput>,
) {}
fn get_tasks(&mut self) -> AnyResult<Vec<JoinHandle<()>>> {
Ok(vec![])
}
fn get_login_processors(&self) -> Vec<ProcessorFunction> {
vec![]
}
fn get_realm_processors(&self) -> Vec<ProcessorFunction> {
vec![]
}
fn get_one_time_handler_maps(&self) -> Vec<BTreeMap<u16, ProcessorResult>> {
vec![]
}
fn get_initial_processors(&self) -> Vec<ProcessorFunction> {
vec![]
}
}
The approach is the same as in Tentacli (just look at how processors and handlers are implemented).
If you need to provide some custom opcode handlers (or add additional handlers to the existing ones), you should group your handlers into processors (as it is done in tentacli) and then use the get_login_processors
or get_realm_processors
methods to return those processors:
// for example you can look into wotlk_login and wotlk_realm features
fn get_login_processors(&self) -> Vec<ProcessorFunction> {
vec![
Box::new(AuthProcessor::get_handlers),
]
}
// or
fn get_realm_processors(&self) -> Vec<ProcessorFunction> {
vec![
Box::new(ChatProcessor::get_handlers),
Box::new(ObjectProcessor::get_handlers),
Box::new(PlayerProcessor::get_handlers),
Box::new(RealmProcessor::get_handlers),
Box::new(SpellProcessor::get_handlers),
Box::new(WardenProcessor::get_handlers),
]
}
Method get_initial_processors
is useful when you need to process some action only once. After call handler will be removed from the memory.
And last get_initial_processors
can be used when you need to call some actions at the beginning. For example, to send initial packet to the server etc.