fix: voice works again
This commit is contained in:
parent
4faf25165d
commit
f5c5e1cc5e
|
@ -3,7 +3,7 @@ use crate::types;
|
||||||
use super::*;
|
use super::*;
|
||||||
|
|
||||||
/// The amount of time we wait for a heartbeat ack before resending our heartbeat in ms
|
/// The amount of time we wait for a heartbeat ack before resending our heartbeat in ms
|
||||||
const HEARTBEAT_ACK_TIMEOUT: u64 = 2000;
|
pub const HEARTBEAT_ACK_TIMEOUT: u64 = 2000;
|
||||||
|
|
||||||
/// Handles sending heartbeats to the gateway in another thread
|
/// Handles sending heartbeats to the gateway in another thread
|
||||||
#[allow(dead_code)] // FIXME: Remove this, once HeartbeatHandler is used
|
#[allow(dead_code)] // FIXME: Remove this, once HeartbeatHandler is used
|
||||||
|
|
|
@ -128,7 +128,7 @@ impl<T: WebSocketEvent> GatewayEvent<T> {
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Notifies the observers of the GatewayEvent.
|
/// Notifies the observers of the GatewayEvent.
|
||||||
async fn notify(&self, new_event_data: T) {
|
pub(crate) async fn notify(&self, new_event_data: T) {
|
||||||
for observer in &self.observers {
|
for observer in &self.observers {
|
||||||
observer.update(&new_event_data).await;
|
observer.update(&new_event_data).await;
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,7 +2,6 @@ use futures_util::stream::{SplitSink, SplitStream};
|
||||||
use futures_util::SinkExt;
|
use futures_util::SinkExt;
|
||||||
use futures_util::StreamExt;
|
use futures_util::StreamExt;
|
||||||
use log::{debug, info, trace, warn};
|
use log::{debug, info, trace, warn};
|
||||||
use native_tls::TlsConnector;
|
|
||||||
use serde_json::json;
|
use serde_json::json;
|
||||||
use std::sync::Arc;
|
use std::sync::Arc;
|
||||||
use std::time::Duration;
|
use std::time::Duration;
|
||||||
|
@ -16,7 +15,7 @@ use tokio_tungstenite::MaybeTlsStream;
|
||||||
use tokio_tungstenite::{connect_async_tls_with_config, Connector, WebSocketStream};
|
use tokio_tungstenite::{connect_async_tls_with_config, Connector, WebSocketStream};
|
||||||
|
|
||||||
use crate::errors::VoiceGatewayError;
|
use crate::errors::VoiceGatewayError;
|
||||||
use crate::gateway::{GatewayEvent, HEARTBEAT_ACK_TIMEOUT};
|
use crate::gateway::{heartbeat::HEARTBEAT_ACK_TIMEOUT, GatewayEvent};
|
||||||
use crate::types::{
|
use crate::types::{
|
||||||
self, SelectProtocol, Speaking, VoiceGatewayReceivePayload, VoiceGatewaySendPayload,
|
self, SelectProtocol, Speaking, VoiceGatewayReceivePayload, VoiceGatewaySendPayload,
|
||||||
VoiceIdentify, WebSocketEvent, VOICE_BACKEND_VERSION, VOICE_CLIENT_CONNECT_FLAGS,
|
VoiceIdentify, WebSocketEvent, VOICE_BACKEND_VERSION, VOICE_CLIENT_CONNECT_FLAGS,
|
||||||
|
@ -203,12 +202,21 @@ impl VoiceGateway {
|
||||||
let processed_url = format!("wss://{}/?v=7", websocket_url);
|
let processed_url = format!("wss://{}/?v=7", websocket_url);
|
||||||
trace!("Created voice socket url: {}", processed_url.clone());
|
trace!("Created voice socket url: {}", processed_url.clone());
|
||||||
|
|
||||||
|
let mut roots = rustls::RootCertStore::empty();
|
||||||
|
for cert in rustls_native_certs::load_native_certs().expect("could not load platform certs")
|
||||||
|
{
|
||||||
|
roots.add(&rustls::Certificate(cert.0)).unwrap();
|
||||||
|
}
|
||||||
let (websocket_stream, _) = match connect_async_tls_with_config(
|
let (websocket_stream, _) = match connect_async_tls_with_config(
|
||||||
&processed_url,
|
&processed_url,
|
||||||
None,
|
None,
|
||||||
false,
|
false,
|
||||||
Some(Connector::NativeTls(
|
Some(Connector::Rustls(
|
||||||
TlsConnector::builder().build().unwrap(),
|
rustls::ClientConfig::builder()
|
||||||
|
.with_safe_defaults()
|
||||||
|
.with_root_certificates(roots)
|
||||||
|
.with_no_client_auth()
|
||||||
|
.into(),
|
||||||
)),
|
)),
|
||||||
)
|
)
|
||||||
.await
|
.await
|
||||||
|
|
Loading…
Reference in New Issue