Refactor
Updated handlers by spliting the TcpStream in half to allow reading and writing data at the same time. This fixes an issue where you are unable to get chat messages until the client sends a packet to the server Fixed client id's by adding the id manager Added shout chat handling
This commit is contained in:
@@ -1,6 +1,8 @@
|
||||
use std::collections::HashMap;
|
||||
use std::sync::Arc;
|
||||
use std::fmt;
|
||||
use tokio::net::TcpStream;
|
||||
use tokio::io::{WriteHalf};
|
||||
|
||||
use crate::handlers::chat_client::ChatClientHandler;
|
||||
|
||||
@@ -9,9 +11,12 @@ pub struct ConnectionState {
|
||||
pub user_id: Option<String>,
|
||||
pub session_id: Option<String>,
|
||||
pub character_id: Option<i8>,
|
||||
pub character_name: Option<String>,
|
||||
pub character_list: Option<Vec<u32>>,
|
||||
pub additional_data: HashMap<String, String>, // Flexible data storage
|
||||
pub client_id: u16,
|
||||
pub chat_handler: Option<Arc<ChatClientHandler>>,
|
||||
pub writer: Option<Arc<tokio::sync::Mutex<WriteHalf<TcpStream>>>>,
|
||||
}
|
||||
|
||||
impl ConnectionState {
|
||||
@@ -20,9 +25,12 @@ impl ConnectionState {
|
||||
user_id: None,
|
||||
session_id: None,
|
||||
character_id: None,
|
||||
character_name: None,
|
||||
character_list: None,
|
||||
additional_data: HashMap::new(),
|
||||
client_id: 0,
|
||||
chat_handler: None,
|
||||
writer: None,
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -33,9 +41,12 @@ impl fmt::Debug for ConnectionState {
|
||||
.field("user_id", &self.user_id)
|
||||
.field("session_id", &self.session_id)
|
||||
.field("character_id", &self.character_id)
|
||||
.field("character_name", &self.character_name)
|
||||
.field("character_list", &self.character_list)
|
||||
.field("additional_data", &self.additional_data)
|
||||
.field("client_id", &self.client_id)
|
||||
.field("chat_handler", &self.chat_handler.as_ref().map(|_| "<chat handler>"))
|
||||
.field("writer", &self.writer.as_ref().map(|_| "<writer>"))
|
||||
.finish()
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user