use anyhow::{Result as AnyResult};
use std::sync::{Arc, Mutex as SyncMutex};
use tokio::sync::Mutex;
pub mod auth;
pub mod chat;
pub mod config;
pub mod custom_fields;
pub mod opcodes;
pub mod movement;
pub mod player;
pub mod position;
pub mod realm;
pub mod shared;
pub mod spell;
pub mod trade;
pub mod update_data;
pub mod update_fields;
pub mod warden;
pub mod world;
pub mod errors;
pub mod object;
use chat::{Message};
use player::{Player};
use realm::Realm;
use crate::PacketHandler;
use crate::types::shared::{DataStorage, Session};
#[derive(Debug, Clone)]
pub enum Signal {
Reconnect,
}
#[derive(Debug)]
pub struct HandlerInput {
pub session: Arc<Mutex<Session>>,
pub data: Vec<u8>,
pub data_storage: Arc<SyncMutex<DataStorage>>,
pub opcode: u16,
}
#[allow(dead_code)]
#[derive(Debug, Clone)]
pub enum HandlerOutput {
ChatMessage(Message),
Data((u32, Vec<u8>, String)),
TransferCharactersList(Vec<Player>),
TransferRealmsList(Vec<Realm>),
IdentifyMe(u64),
ConnectionRequest(String, u16),
Drop,
ExitRequest,
Freeze,
SelectCharacter(Player),
SelectRealm(Realm),
ResponseMessage(String, Option<String>),
RequestMessage(String, Option<String>),
DebugMessage(String, Option<String>),
SuccessMessage(String, Option<String>),
ErrorMessage(String, Option<String>),
}
pub type HandlerResult = AnyResult<Vec<HandlerOutput>>;
pub type ProcessorResult = Vec<Box<dyn PacketHandler + Send>>;
pub type ProcessorFunction = Box<dyn Fn(u16) -> ProcessorResult + Send>;
#[derive(Default, Debug, Clone)]
pub struct IncomingPacket {
pub opcode: u16,
pub body: Vec<u8>,
}
#[derive(Default, Debug, Clone)]
pub struct OutgoingPacket {
pub opcode: u32,
pub data: Vec<u8>,
pub json_details: String,
}