Change euph packet representation

This commit is contained in:
Joscha 2022-06-22 20:32:55 +02:00
parent 03c1fe7f34
commit a4a8174ea3
8 changed files with 506 additions and 415 deletions

View file

@ -2,10 +2,7 @@
use serde::{Deserialize, Serialize};
use super::{
has_packet_type, AuthOption, HasPacketType, Message, PacketType, PersonalAccountView,
SessionView, Snowflake, Time, UserId,
};
use super::{AuthOption, Message, PersonalAccountView, SessionView, Snowflake, Time, UserId};
/// Indicates that access to a room is denied.
#[derive(Debug, Clone, Serialize, Deserialize)]
@ -20,8 +17,6 @@ pub struct BounceEvent {
pub ip: Option<String>,
}
has_packet_type!(BounceEvent);
/// Indicates that the session is being closed. The client will subsequently be
/// disconnected.
///
@ -33,8 +28,6 @@ pub struct DisconnectEvent {
pub reason: String,
}
has_packet_type!(DisconnectEvent);
/// Sent by the server to the client when a session is started.
///
/// It includes information about the client's authentication and associated
@ -58,14 +51,10 @@ pub struct HelloEvent {
pub version: String,
}
has_packet_type!(HelloEvent);
/// Indicates a session just joined the room.
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct JoinEvent(pub SessionView);
has_packet_type!(JoinEvent);
/// Sent to all sessions of an agent when that agent is logged in (except for
/// the session that issued the login command).
#[derive(Debug, Clone, Serialize, Deserialize)]
@ -73,15 +62,11 @@ pub struct LoginEvent {
pub account_id: Snowflake,
}
has_packet_type!(LoginEvent);
/// Sent to all sessions of an agent when that agent is logged out (except for
/// the session that issued the logout command).
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct LogoutEvent;
has_packet_type!(LogoutEvent);
/// Indicates some server-side event that impacts the presence of sessions in a
/// room.
///
@ -97,8 +82,6 @@ pub struct NetworkEvent {
pub server_era: String,
}
has_packet_type!(NetworkEvent);
/// Announces a nick change by another session in the room.
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct NickEvent {
@ -112,8 +95,6 @@ pub struct NickEvent {
pub to: String,
}
has_packet_type!(NickEvent);
/// Indicates that a message in the room has been modified or deleted.
///
/// If the client offers a user interface and the indicated message is currently
@ -129,14 +110,10 @@ pub struct EditMessageEvent {
pub message: Message,
}
has_packet_type!(EditMessageEvent);
/// Indicates a session just disconnected from the room.
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct PartEvent(pub SessionView);
has_packet_type!(PartEvent);
/// Represents a server-to-client ping.
///
/// The client should send back a ping-reply with the same value for the time
@ -150,8 +127,6 @@ pub struct PingEvent {
pub next: Time,
}
has_packet_type!(PingEvent);
/// Informs the client that another user wants to chat with them privately.
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct PmInitiateEvent {
@ -165,14 +140,10 @@ pub struct PmInitiateEvent {
pub pm_id: Snowflake,
}
has_packet_type!(PmInitiateEvent);
/// Indicates a message received by the room from another session.
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct SendEvent(pub Message);
has_packet_type!(SendEvent);
/// Indicates that a session has successfully joined a room.
///
/// It also offers a snapshot of the rooms state and recent history.
@ -197,5 +168,3 @@ pub struct SnapshotEvent {
/// If given, this room is for private chat with the given user.
pub pm_with_user_id: Option<String>,
}
has_packet_type!(SnapshotEvent);