mirror of
https://gitlab.com/veloren/veloren.git
synced 2024-08-30 18:12:32 +00:00
- Instread we have a dedicated thread that will async wait for new participants to connect and then notify the main thread - registry no longer sends a view distance with it. - remove ClientMsg::Command again as it's unused
45 lines
1.1 KiB
Rust
45 lines
1.1 KiB
Rust
pub mod client;
|
|
pub mod ecs_packet;
|
|
pub mod server;
|
|
|
|
// Reexports
|
|
pub use self::{
|
|
client::{
|
|
ClientGeneralMsg, ClientInGameMsg, ClientNotInGameMsg, ClientRegisterMsg, ClientType,
|
|
},
|
|
ecs_packet::EcsCompPacket,
|
|
server::{
|
|
CharacterInfo, DisconnectReason, InviteAnswer, Notification, PlayerInfo, PlayerListUpdate,
|
|
RegisterError, ServerGeneralMsg, ServerInGameMsg, ServerInfo, ServerInitMsg,
|
|
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)
|
|
}
|
|
}
|