Skip to content

Commit

Permalink
Merge branch 'dev' into primary
Browse files Browse the repository at this point in the history
  • Loading branch information
sergio-ivanuzzo committed Aug 25, 2024
2 parents 561f682 + a462b81 commit 321ac5c
Show file tree
Hide file tree
Showing 9 changed files with 28 additions and 56 deletions.
16 changes: 8 additions & 8 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "tentacli"
version = "13.0.0"
version = "13.0.1"
edition = "2021"
authors = ["Sergio Ivanuzzo <[email protected]>"]
description = "Console wow-client, it can be used either as a standalone application or integrated into your own project."
Expand All @@ -16,23 +16,23 @@ repository = "https://github.com/idewave/tentacli"

[dependencies]
anyhow = "1.0"
async-broadcast = "0.7.0"
async-broadcast = "0.7.1"
async-trait = { version = "0.1.57", optional = true }
bitflags = { version = "2.4.2", optional = true }
byteorder = "1.4.3"
bitflags = { version = "2.6.0", optional = true }
byteorder = "1.5.0"
cfg-if = { version = "1.0.0", features = [] }
chrono = { version = "0.4", optional = true }
colored = { version = "2.1.0", optional = true }
crossterm = { version = "0.27.0", optional = true }
futures = "0.3.21"
crossterm = { version = "0.28.1", optional = true }
futures = { version = "0.3" }
rand = { version = "0.8.5", optional = true }
regex = { version = "1.5.6", optional = true }
regex = { version = "1.10.6", optional = true }
serde = { version = "1.0", features = ["derive"] }
sha-1 = { version = "0.9.8", optional = true }
tentacli-crypto = "0.1.0"
tentacli-formatters = "0.1.0"
tentacli-packet = "7.0.0"
tentacli-traits = "6.0.0"
tentacli-traits = "7.0.0"
tentacli-utils = "2.1.0"
tokio = { version = "1", features = ["sync", "net", "io-util", "macros", "time", "rt-multi-thread"] }
#tokio-util = { version = "0.7.10", features = ["io"] }
Expand Down
8 changes: 1 addition & 7 deletions src/features/console/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,19 +5,13 @@ use colored::*;
use tentacli_traits::{Feature, FeatureError};
use tentacli_traits::types::HandlerOutput;

#[derive(Default)]
pub struct Console {
_receiver: Option<BroadcastReceiver<HandlerOutput>>,
_sender: Option<BroadcastSender<HandlerOutput>>,
}

impl Feature for Console {
fn new() -> Self where Self: Sized {
Self {
_receiver: None,
_sender: None,
}
}

fn set_broadcast_channel(
&mut self,
sender: BroadcastSender<HandlerOutput>,
Expand Down
8 changes: 1 addition & 7 deletions src/features/ui/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ use crate::features::ui::types::{LoggerOutput, UIEventFlags};

pub const MARGIN: u16 = 1;

#[derive(Default)]
pub struct UI {
_receiver: Option<BroadcastReceiver<HandlerOutput>>,
_sender: Option<BroadcastSender<HandlerOutput>>,
Expand All @@ -61,13 +62,6 @@ impl UI {
}

impl Feature for UI {
fn new() -> Self where Self: Sized {
Self {
_receiver: None,
_sender: None,
}
}

fn set_broadcast_channel(
&mut self,
sender: BroadcastSender<HandlerOutput>,
Expand Down
24 changes: 8 additions & 16 deletions src/features/wotlk_login/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,19 +15,13 @@ use auth::AuthProcessor;
use crate::features::wotlk_login::realm::packet::LogoutOutcoming;
use crate::features::wotlk_login::realm::RealmProcessor;

#[derive(Default)]
pub struct WotlkLogin {
_receiver: Option<BroadcastReceiver<HandlerOutput>>,
_sender: Option<BroadcastSender<HandlerOutput>>,
}

impl Feature for WotlkLogin {
fn new() -> Self where Self: Sized {
Self {
_receiver: None,
_sender: None,
}
}

fn set_broadcast_channel(
&mut self,
sender: BroadcastSender<HandlerOutput>,
Expand All @@ -44,15 +38,13 @@ impl Feature for WotlkLogin {
let handle_exit = || {
tokio::spawn(async move {
loop {
if let Ok(output) = receiver.recv().await {
if let HandlerOutput::ExitRequest = output {
sender.broadcast(
HandlerOutput::Data(LogoutOutcoming::default()
.unpack_with_client_opcode(Opcode::CMSG_LOGOUT_REQUEST)
.unwrap()
)
).await.unwrap();
}
if let Ok(HandlerOutput::ExitRequest) = receiver.recv().await {
sender.broadcast(
HandlerOutput::Data(LogoutOutcoming::default()
.unpack_with_client_opcode(Opcode::CMSG_LOGOUT_REQUEST)
.unwrap()
)
).await.unwrap();
}
}
})
Expand Down
5 changes: 1 addition & 4 deletions src/features/wotlk_realm/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,9 @@ use realm::RealmProcessor;
use spell::SpellProcessor;
use warden::WardenProcessor;

#[derive(Default)]
pub struct WotlkRealm;
impl Feature for WotlkRealm {
fn new() -> Self {
Self {}
}

fn get_realm_processors(&self) -> Vec<ProcessorFunction> {
vec![
Box::new(ChatProcessor::get_handlers),
Expand Down
10 changes: 2 additions & 8 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,19 +29,13 @@
//!
//! #[tokio::main]
//! async fn main() {
//! #[derive(Default)]
//! pub struct MyFeature {
//! _receiver: Option<BroadcastReceiver<HandlerOutput>>,
//! _sender: Option<BroadcastSender<HandlerOutput>>,
//! }
//!
//! impl Feature for MyFeature {
//! fn new() -> Self where Self: Sized {
//! Self {
//! _receiver: None,
//! _sender: None,
//! }
//! }
//!
//! fn set_broadcast_channel(
//! &mut self,
//! sender: BroadcastSender<HandlerOutput>,
Expand Down Expand Up @@ -90,7 +84,7 @@
//! }
//!
//! let options = RunOptions {
//! external_features: vec![Box::new(MyFeature::new())],
//! external_features: vec![Box::new(MyFeature::default())],
//! account: "account_name",
//! config_path: "./dir/another_dir/ConfigFileName.yml",
//! dotenv_path: "./path/to/.env"
Expand Down
8 changes: 4 additions & 4 deletions src/primary/client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -161,25 +161,25 @@ impl Client {
if #[cfg(feature = "ui")] {
use crate::features::ui::UI;

features.push(Box::new(UI::new()));
features.push(Box::new(UI::default()));
} else if #[cfg(feature = "console")] {
use crate::features::console::Console;

features.push(Box::new(Console::new()));
features.push(Box::new(Console::default()));
}
}

cfg_if! {
if #[cfg(feature = "wotlk_login")] {
use crate::features::wotlk_login::WotlkLogin;
features.push(Box::new(WotlkLogin::new()));
features.push(Box::new(WotlkLogin::default()));
}
}

cfg_if! {
if #[cfg(feature = "wotlk_realm")] {
use crate::features::wotlk_realm::WotlkRealm;
features.push(Box::new(WotlkRealm::new()));
features.push(Box::new(WotlkRealm::default()));
}
}

Expand Down
2 changes: 1 addition & 1 deletion src/primary/traits/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "tentacli-traits"
version = "6.0.0"
version = "7.0.0"
edition = "2021"
authors = ["Sergio Ivanuzzo <[email protected]>"]
description = "Traits and types for tentacli and related projects"
Expand Down
3 changes: 2 additions & 1 deletion src/primary/traits/src/feature.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,16 @@ use async_broadcast::{Receiver as BroadcastReceiver, Sender as BroadcastSender};
use crate::types::{HandlerOutput, ProcessorFunction, ProcessorResult};

pub trait Feature: Send {
fn new() -> Self where Self: Sized;
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![]
}
Expand Down

0 comments on commit 321ac5c

Please sign in to comment.