Compare commits
1 Commits
953977e04e
...
3a65ff3ffc
Author | SHA1 | Date |
---|---|---|
kozabrada123 | 3a65ff3ffc |
|
@ -46,8 +46,6 @@ pub struct Session {
|
||||||
pub ready: GatewayEvent<types::GatewayReady>,
|
pub ready: GatewayEvent<types::GatewayReady>,
|
||||||
pub ready_supplemental: GatewayEvent<types::GatewayReadySupplemental>,
|
pub ready_supplemental: GatewayEvent<types::GatewayReadySupplemental>,
|
||||||
pub replace: GatewayEvent<types::SessionsReplace>,
|
pub replace: GatewayEvent<types::SessionsReplace>,
|
||||||
pub reconnect: GatewayEvent<types::GatewayReconnect>,
|
|
||||||
pub invalid: GatewayEvent<types::GatewayInvalidSession>,
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Default, Debug)]
|
#[derive(Default, Debug)]
|
||||||
|
|
|
@ -14,9 +14,8 @@ use super::*;
|
||||||
use super::{Sink, Stream};
|
use super::{Sink, Stream};
|
||||||
use crate::types::{
|
use crate::types::{
|
||||||
self, AutoModerationRule, AutoModerationRuleUpdate, Channel, ChannelCreate, ChannelDelete,
|
self, AutoModerationRule, AutoModerationRuleUpdate, Channel, ChannelCreate, ChannelDelete,
|
||||||
ChannelUpdate, GatewayInvalidSession, GatewayReconnect, Guild, GuildRoleCreate,
|
ChannelUpdate, Guild, GuildRoleCreate, GuildRoleUpdate, JsonField, RoleObject, SourceUrlField,
|
||||||
GuildRoleUpdate, JsonField, RoleObject, SourceUrlField, ThreadUpdate, UpdateMessage,
|
ThreadUpdate, UpdateMessage, WebSocketEvent,
|
||||||
WebSocketEvent,
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
|
@ -339,42 +338,10 @@ impl Gateway {
|
||||||
.unwrap();
|
.unwrap();
|
||||||
}
|
}
|
||||||
GATEWAY_RECONNECT => {
|
GATEWAY_RECONNECT => {
|
||||||
trace!("GW: Received Reconnect");
|
todo!()
|
||||||
|
|
||||||
let reconnect = GatewayReconnect {};
|
|
||||||
|
|
||||||
self.events
|
|
||||||
.lock()
|
|
||||||
.await
|
|
||||||
.session
|
|
||||||
.reconnect
|
|
||||||
.notify(reconnect)
|
|
||||||
.await;
|
|
||||||
}
|
}
|
||||||
GATEWAY_INVALID_SESSION => {
|
GATEWAY_INVALID_SESSION => {
|
||||||
trace!("GW: Received Invalid Session");
|
todo!()
|
||||||
|
|
||||||
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;
|
|
||||||
}
|
}
|
||||||
// Starts our heartbeat
|
// Starts our heartbeat
|
||||||
// We should have already handled this in gateway init
|
// We should have already handled this in gateway init
|
||||||
|
|
|
@ -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 {}
|
|
|
@ -14,14 +14,12 @@ pub use hello::*;
|
||||||
pub use identify::*;
|
pub use identify::*;
|
||||||
pub use integration::*;
|
pub use integration::*;
|
||||||
pub use interaction::*;
|
pub use interaction::*;
|
||||||
pub use invalid_session::*;
|
|
||||||
pub use invite::*;
|
pub use invite::*;
|
||||||
pub use lazy_request::*;
|
pub use lazy_request::*;
|
||||||
pub use message::*;
|
pub use message::*;
|
||||||
pub use passive_update::*;
|
pub use passive_update::*;
|
||||||
pub use presence::*;
|
pub use presence::*;
|
||||||
pub use ready::*;
|
pub use ready::*;
|
||||||
pub use reconnect::*;
|
|
||||||
pub use relationship::*;
|
pub use relationship::*;
|
||||||
pub use request_members::*;
|
pub use request_members::*;
|
||||||
pub use resume::*;
|
pub use resume::*;
|
||||||
|
@ -62,14 +60,12 @@ mod hello;
|
||||||
mod identify;
|
mod identify;
|
||||||
mod integration;
|
mod integration;
|
||||||
mod interaction;
|
mod interaction;
|
||||||
mod invalid_session;
|
|
||||||
mod invite;
|
mod invite;
|
||||||
mod lazy_request;
|
mod lazy_request;
|
||||||
mod message;
|
mod message;
|
||||||
mod passive_update;
|
mod passive_update;
|
||||||
mod presence;
|
mod presence;
|
||||||
mod ready;
|
mod ready;
|
||||||
mod reconnect;
|
|
||||||
mod relationship;
|
mod relationship;
|
||||||
mod request_members;
|
mod request_members;
|
||||||
mod resume;
|
mod resume;
|
||||||
|
|
|
@ -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 {}
|
|
Loading…
Reference in New Issue