Compare commits

..

1 Commits

Author SHA1 Message Date
kozabrada123 3a65ff3ffc
Merge a3ea5c0975 into 51c676c000 2024-03-09 18:36:07 +00:00
5 changed files with 4 additions and 72 deletions

View File

@ -46,8 +46,6 @@ pub struct Session {
pub ready: GatewayEvent<types::GatewayReady>,
pub ready_supplemental: GatewayEvent<types::GatewayReadySupplemental>,
pub replace: GatewayEvent<types::SessionsReplace>,
pub reconnect: GatewayEvent<types::GatewayReconnect>,
pub invalid: GatewayEvent<types::GatewayInvalidSession>,
}
#[derive(Default, Debug)]

View File

@ -14,9 +14,8 @@ use super::*;
use super::{Sink, Stream};
use crate::types::{
self, AutoModerationRule, AutoModerationRuleUpdate, Channel, ChannelCreate, ChannelDelete,
ChannelUpdate, GatewayInvalidSession, GatewayReconnect, Guild, GuildRoleCreate,
GuildRoleUpdate, JsonField, RoleObject, SourceUrlField, ThreadUpdate, UpdateMessage,
WebSocketEvent,
ChannelUpdate, Guild, GuildRoleCreate, GuildRoleUpdate, JsonField, RoleObject, SourceUrlField,
ThreadUpdate, UpdateMessage, WebSocketEvent,
};
#[derive(Debug)]
@ -339,42 +338,10 @@ impl Gateway {
.unwrap();
}
GATEWAY_RECONNECT => {
trace!("GW: Received Reconnect");
let reconnect = GatewayReconnect {};
self.events
.lock()
.await
.session
.reconnect
.notify(reconnect)
.await;
todo!()
}
GATEWAY_INVALID_SESSION => {
trace!("GW: Received Invalid Session");
let mut resumable: bool = false;
if let Some(raw_value) = gateway_payload.event_data {
if let Ok(deserialized) = serde_json::from_str(raw_value.get()) {
resumable = deserialized;
} else {
warn!("Failed to parse part of INVALID_SESSION ('{}' as bool), assuming non-resumable", raw_value.get());
}
} else {
warn!("Failed to parse part of INVALID_SESSION ('d' missing), assuming non-resumable");
}
let invalid_session = GatewayInvalidSession { resumable };
self.events
.lock()
.await
.session
.invalid
.notify(invalid_session)
.await;
todo!()
}
// Starts our heartbeat
// We should have already handled this in gateway init

View File

@ -1,17 +0,0 @@
use serde::{Deserialize, Serialize};
use super::WebSocketEvent;
#[derive(Debug, Deserialize, Serialize, Default, Clone)]
/// Your session is now invalid.
///
/// Either reauthenticate and reidentify or resume if possible.
///
/// # Reference
/// See <https://docs.discord.sex/topics/gateway-events#invalid-session>
pub struct GatewayInvalidSession {
#[serde(rename = "d")]
pub resumable: bool,
}
impl WebSocketEvent for GatewayInvalidSession {}

View File

@ -14,14 +14,12 @@ pub use hello::*;
pub use identify::*;
pub use integration::*;
pub use interaction::*;
pub use invalid_session::*;
pub use invite::*;
pub use lazy_request::*;
pub use message::*;
pub use passive_update::*;
pub use presence::*;
pub use ready::*;
pub use reconnect::*;
pub use relationship::*;
pub use request_members::*;
pub use resume::*;
@ -62,14 +60,12 @@ mod hello;
mod identify;
mod integration;
mod interaction;
mod invalid_session;
mod invite;
mod lazy_request;
mod message;
mod passive_update;
mod presence;
mod ready;
mod reconnect;
mod relationship;
mod request_members;
mod resume;

View File

@ -1,12 +0,0 @@
use serde::{Deserialize, Serialize};
use super::WebSocketEvent;
#[derive(Debug, Deserialize, Serialize, Default, Clone)]
/// "The reconnect event is dispatched when a client should reconnect to the Gateway (and resume their existing session, if they have one). This event usually occurs during deploys to migrate sessions gracefully off old hosts"
///
/// # Reference
/// See <https://docs.discord.sex/topics/gateway-events#reconnect>
pub struct GatewayReconnect {}
impl WebSocketEvent for GatewayReconnect {}