Add Webrtc Identify & Ready
This commit is contained in:
parent
f95641a0fa
commit
045c2f9578
|
@ -2,7 +2,7 @@ use crate::types::events::{PresenceUpdate, WebSocketEvent};
|
|||
use serde::{Deserialize, Serialize};
|
||||
use serde_with::serde_as;
|
||||
|
||||
#[derive(Debug, Deserialize, Serialize)]
|
||||
#[derive(Debug, Deserialize, Serialize, Clone)]
|
||||
pub struct GatewayIdentifyPayload {
|
||||
pub token: String,
|
||||
pub properties: GatewayIdentifyConnectionProps,
|
||||
|
|
|
@ -26,6 +26,8 @@ pub use user::*;
|
|||
pub use voice::*;
|
||||
pub use webhooks::*;
|
||||
|
||||
pub use webrtc::*;
|
||||
|
||||
mod application;
|
||||
mod auto_moderation;
|
||||
mod call;
|
||||
|
@ -52,6 +54,8 @@ mod user;
|
|||
mod voice;
|
||||
mod webhooks;
|
||||
|
||||
mod webrtc;
|
||||
|
||||
pub trait WebSocketEvent {}
|
||||
|
||||
#[derive(Debug, Default, Serialize, Clone)]
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
use crate::types::{events::WebSocketEvent, VoiceState};
|
||||
use crate::types::{events::WebSocketEvent, Snowflake, VoiceState};
|
||||
use serde::{Deserialize, Serialize};
|
||||
|
||||
#[derive(Debug, Deserialize, Serialize, Default)]
|
||||
|
@ -34,7 +34,7 @@ impl WebSocketEvent for VoiceStateUpdate {}
|
|||
/// Received to indicate which voice endpoint, token and guild_id to use;
|
||||
pub struct VoiceServerUpdate {
|
||||
pub token: String,
|
||||
pub guild_id: String,
|
||||
pub guild_id: Snowflake,
|
||||
pub endpoint: Option<String>,
|
||||
}
|
||||
|
||||
|
|
|
@ -0,0 +1,18 @@
|
|||
use crate::types::{Snowflake, WebSocketEvent};
|
||||
use serde::{Deserialize, Serialize};
|
||||
|
||||
#[derive(Debug, Deserialize, Serialize, Default, Clone)]
|
||||
/// The identify payload for the webrtc stream;
|
||||
/// Contains info to begin a webrtc connection;
|
||||
/// See https://discord.com/developers/docs/topics/voice-connections#establishing-a-voice-websocket-connection-example-voice-identify-payload;
|
||||
pub struct VoiceIdentify {
|
||||
server_id: Snowflake,
|
||||
user_id: Snowflake,
|
||||
session_id: String,
|
||||
token: String,
|
||||
#[serde(skip_serializing_if = "Option::is_none")]
|
||||
/// Undocumented field, but is also in discord client comms
|
||||
video: Option<bool>,
|
||||
}
|
||||
|
||||
impl WebSocketEvent for VoiceIdentify {}
|
|
@ -0,0 +1,5 @@
|
|||
pub use identify::*;
|
||||
pub use ready::*;
|
||||
|
||||
mod identify;
|
||||
mod ready;
|
|
@ -0,0 +1,29 @@
|
|||
use std::net::Ipv4Addr;
|
||||
|
||||
use crate::types::WebSocketEvent;
|
||||
use serde::{Deserialize, Serialize};
|
||||
|
||||
#[derive(Debug, Deserialize, Serialize, Clone)]
|
||||
/// The ready event for the webrtc stream;
|
||||
/// Used to give info after the identify event;
|
||||
/// See https://discord.com/developers/docs/topics/voice-connections#establishing-a-voice-websocket-connection-example-voice-ready-payload;
|
||||
pub struct VoiceReady {
|
||||
ssrc: u8,
|
||||
ip: Ipv4Addr,
|
||||
port: u8,
|
||||
modes: Vec<String>,
|
||||
// Heartbeat interval is also sent, but is "an erroneous field and should be ignored. The correct heartbeat_interval value comes from the Hello payload."
|
||||
}
|
||||
|
||||
impl Default for VoiceReady {
|
||||
fn default() -> Self {
|
||||
VoiceReady {
|
||||
ssrc: 1,
|
||||
ip: Ipv4Addr::UNSPECIFIED,
|
||||
port: 0,
|
||||
modes: Vec::new(),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl WebSocketEvent for VoiceReady {}
|
Loading…
Reference in New Issue