mirror of
https://gitlab.com/veloren/veloren.git
synced 2024-08-30 18:12:32 +00:00
Rather than having a single Stream to handle ALL data, seperate into multiple streams: - Ping Stream, for seperate PINGS - Register Stream, only used till the client is registered, then no longer used! - General Stream, used for msg that can occur always - NotInGame Stream, used for everything NOT ingame, e.g. Character Screen - InGame Stream, used for all GAME data, players, terrain, entities, etc... This version does compile, and gets the client registered (with auth too) but doesnt get to the char screen yet. This fixes also the ignoring messages problem we had, as we are not sending data to the register stream! This fixes also the problem that the server had to sleep for the Stream Creation, as the Server is now creating the streams and client has to sleep.
43 lines
1.1 KiB
Rust
43 lines
1.1 KiB
Rust
pub mod client;
|
|
pub mod ecs_packet;
|
|
pub mod server;
|
|
|
|
// Reexports
|
|
pub use self::{
|
|
client::{ClientInGameMsg, ClientMsg, ClientNotInGameMsg, ClientRegisterMsg, ClientType},
|
|
ecs_packet::EcsCompPacket,
|
|
server::{
|
|
CharacterInfo, DisconnectReason, InviteAnswer, Notification, PlayerInfo, PlayerListUpdate,
|
|
RegisterError, ServerInGameMsg, ServerInfo, ServerInitMsg, ServerMsg, ServerNotInGameMsg,
|
|
ServerRegisterAnswerMsg,
|
|
},
|
|
};
|
|
use serde::{Deserialize, Serialize};
|
|
|
|
#[derive(Debug, Clone, Copy, PartialEq, Serialize, Deserialize)]
|
|
pub enum ClientIngame {
|
|
Spectator,
|
|
Character,
|
|
}
|
|
|
|
#[derive(Debug, Clone, Copy, PartialEq, Serialize, Deserialize)]
|
|
pub enum PingMsg {
|
|
Ping,
|
|
Pong,
|
|
}
|
|
|
|
pub const MAX_BYTES_CHAT_MSG: usize = 256;
|
|
|
|
pub enum ChatMsgValidationError {
|
|
TooLong,
|
|
}
|
|
|
|
pub fn validate_chat_msg(msg: &str) -> Result<(), ChatMsgValidationError> {
|
|
// TODO: Consider using grapheme cluster count instead of size in bytes
|
|
if msg.len() <= MAX_BYTES_CHAT_MSG {
|
|
Ok(())
|
|
} else {
|
|
Err(ChatMsgValidationError::TooLong)
|
|
}
|
|
}
|