veloren/common/src/msg/mod.rs

47 lines
1.2 KiB
Rust
Raw Normal View History

pub mod client;
pub mod ecs_packet;
pub mod server;
pub mod world_packet;
// Reexports
pub use self::{
client::{
ClientCharacterScreen, ClientGeneral, ClientInGame, ClientMsg, ClientRegister, ClientType,
},
ecs_packet::EcsCompPacket,
2020-05-14 16:56:10 +00:00
server::{
2020-09-14 06:16:09 +00:00
CharacterInfo, DisconnectReason, InviteAnswer, Notification, PlayerInfo, PlayerListUpdate,
RegisterError, ServerCharacterScreen, ServerGeneral, ServerInGame, ServerInfo, ServerInit,
ServerMsg, ServerRegisterAnswer,
2020-05-14 16:56:10 +00:00
},
world_packet::WorldMapMsg,
};
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,
}
2019-08-15 21:28:36 +00:00
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)
}
}