fix: blunder

This commit is contained in:
kozabrada123 2023-12-28 09:29:49 +01:00
parent ef4d6cffdb
commit a5e4170641
6 changed files with 15 additions and 15 deletions

View File

@ -7,7 +7,7 @@ use tokio_tungstenite::{
connect_async_tls_with_config, tungstenite, Connector, MaybeTlsStream, WebSocketStream, connect_async_tls_with_config, tungstenite, Connector, MaybeTlsStream, WebSocketStream,
}; };
use crate::{errors::VoiceGatewayError, voice::gateway::VoiceGatewayMesssage}; use crate::{errors::VoiceGatewayError, voice::gateway::VoiceGatewayMessage};
#[derive(Debug, Clone)] #[derive(Debug, Clone)]
pub struct TungsteniteBackend; pub struct TungsteniteBackend;
@ -52,13 +52,13 @@ impl TungsteniteBackend {
} }
} }
impl From<VoiceGatewayMesssage> for tungstenite::Message { impl From<VoiceGatewayMessage> for tungstenite::Message {
fn from(message: VoiceGatewayMesssage) -> Self { fn from(message: VoiceGatewayMessage) -> Self {
Self::Text(message.0) Self::Text(message.0)
} }
} }
impl From<tungstenite::Message> for VoiceGatewayMesssage { impl From<tungstenite::Message> for VoiceGatewayMessage {
fn from(value: tungstenite::Message) -> Self { fn from(value: tungstenite::Message) -> Self {
Self(value.to_string()) Self(value.to_string())
} }

View File

@ -28,7 +28,7 @@ impl WasmBackend {
} }
} }
impl From<GatewayMessage> for WsMessage { impl From<VoiceGatewayMessage> for WsMessage {
fn from(message: VoiceGatewayMessage) -> Self { fn from(message: VoiceGatewayMessage) -> Self {
Self::Text(message.0) Self::Text(message.0)
} }

View File

@ -18,7 +18,7 @@ use crate::{
VOICE_SESSION_UPDATE, VOICE_SPEAKING, VOICE_SSRC_DEFINITION, VOICE_SESSION_UPDATE, VOICE_SPEAKING, VOICE_SSRC_DEFINITION,
}, },
voice::gateway::{ voice::gateway::{
heartbeat::VoiceHeartbeatThreadCommunication, VoiceGatewayMesssage, WebSocketBackend, heartbeat::VoiceHeartbeatThreadCommunication, VoiceGatewayMessage, WebSocketBackend,
}, },
}; };
@ -53,7 +53,7 @@ impl VoiceGateway {
// Wait for the first hello and then spawn both tasks so we avoid nested tasks // Wait for the first hello and then spawn both tasks so we avoid nested tasks
// This automatically spawns the heartbeat task, but from the main thread // This automatically spawns the heartbeat task, but from the main thread
#[cfg(not(target_arch = "wasm32"))] #[cfg(not(target_arch = "wasm32"))]
let msg: VoiceGatewayMesssage = websocket_receive.next().await.unwrap().unwrap().into(); let msg: VoiceGatewayMessage = websocket_receive.next().await.unwrap().unwrap().into();
#[cfg(target_arch = "wasm32")] #[cfg(target_arch = "wasm32")]
let msg: VoiceGatewayMessage = websocket_receive.next().await.unwrap().into(); let msg: VoiceGatewayMessage = websocket_receive.next().await.unwrap().into();
let gateway_payload: VoiceGatewayReceivePayload = serde_json::from_str(&msg.0).unwrap(); let gateway_payload: VoiceGatewayReceivePayload = serde_json::from_str(&msg.0).unwrap();
@ -153,7 +153,7 @@ impl VoiceGateway {
} }
/// This handles a message as a websocket event and updates its events along with the events' observers /// This handles a message as a websocket event and updates its events along with the events' observers
pub async fn handle_message(&mut self, msg: VoiceGatewayMesssage) { pub async fn handle_message(&mut self, msg: VoiceGatewayMessage) {
if msg.0.is_empty() { if msg.0.is_empty() {
return; return;
} }

View File

@ -13,7 +13,7 @@ use crate::types::{
VOICE_SSRC_DEFINITION, VOICE_SSRC_DEFINITION,
}; };
use super::{events::VoiceEvents, Sink, VoiceGatewayMesssage}; use super::{events::VoiceEvents, Sink, VoiceGatewayMessage};
/// Represents a handle to a Voice Gateway connection. /// Represents a handle to a Voice Gateway connection.
/// Using this handle you can send Gateway Events directly. /// Using this handle you can send Gateway Events directly.
@ -35,7 +35,7 @@ impl VoiceGatewayHandle {
}; };
let payload_json = serde_json::to_string(&gateway_payload).unwrap(); let payload_json = serde_json::to_string(&gateway_payload).unwrap();
let message = VoiceGatewayMesssage(payload_json); let message = VoiceGatewayMessage(payload_json);
self.websocket_send self.websocket_send
.lock() .lock()

View File

@ -11,7 +11,7 @@ use tokio::sync::{mpsc::Sender, Mutex};
use crate::{ use crate::{
gateway::heartbeat::HEARTBEAT_ACK_TIMEOUT, gateway::heartbeat::HEARTBEAT_ACK_TIMEOUT,
types::{VoiceGatewaySendPayload, VOICE_HEARTBEAT, VOICE_HEARTBEAT_ACK}, types::{VoiceGatewaySendPayload, VOICE_HEARTBEAT, VOICE_HEARTBEAT_ACK},
voice::gateway::VoiceGatewayMesssage, voice::gateway::VoiceGatewayMessage,
}; };
use super::Sink; use super::Sink;
@ -133,7 +133,7 @@ impl VoiceHeartbeatHandler {
let heartbeat_json = serde_json::to_string(&heartbeat).unwrap(); let heartbeat_json = serde_json::to_string(&heartbeat).unwrap();
let msg = VoiceGatewayMesssage(heartbeat_json); let msg = VoiceGatewayMessage(heartbeat_json);
let send_result = websocket_tx.lock().await.send(msg.into()).await; let send_result = websocket_tx.lock().await.send(msg.into()).await;
if send_result.is_err() { if send_result.is_err() {

View File

@ -3,9 +3,9 @@ use crate::{errors::VoiceGatewayError, types::VoiceGatewayReceivePayload};
/// Represents a messsage received from the webrtc socket. This will be either a [GatewayReceivePayload], containing webrtc events, or a [WebrtcError]. /// Represents a messsage received from the webrtc socket. This will be either a [GatewayReceivePayload], containing webrtc events, or a [WebrtcError].
/// This struct is used internally when handling messages. /// This struct is used internally when handling messages.
#[derive(Clone, Debug)] #[derive(Clone, Debug)]
pub struct VoiceGatewayMesssage(pub String); pub struct VoiceGatewayMessage(pub String);
impl VoiceGatewayMesssage { impl VoiceGatewayMessage {
/// Parses the message as an error; /// Parses the message as an error;
/// Returns the error if succesfully parsed, None if the message isn't an error /// Returns the error if succesfully parsed, None if the message isn't an error
pub fn error(&self) -> Option<VoiceGatewayError> { pub fn error(&self) -> Option<VoiceGatewayError> {
@ -34,6 +34,6 @@ impl VoiceGatewayMesssage {
/// Parses the message as a payload; /// Parses the message as a payload;
/// Returns a result of deserializing /// Returns a result of deserializing
pub fn payload(&self) -> Result<VoiceGatewayReceivePayload, serde_json::Error> { pub fn payload(&self) -> Result<VoiceGatewayReceivePayload, serde_json::Error> {
return serde_json::from_str(&self.0); serde_json::from_str(&self.0)
} }
} }