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

View File

@ -18,7 +18,7 @@ use crate::{
VOICE_SESSION_UPDATE, VOICE_SPEAKING, VOICE_SSRC_DEFINITION,
},
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
// This automatically spawns the heartbeat task, but from the main thread
#[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")]
let msg: VoiceGatewayMessage = websocket_receive.next().await.unwrap().into();
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
pub async fn handle_message(&mut self, msg: VoiceGatewayMesssage) {
pub async fn handle_message(&mut self, msg: VoiceGatewayMessage) {
if msg.0.is_empty() {
return;
}

View File

@ -13,7 +13,7 @@ use crate::types::{
VOICE_SSRC_DEFINITION,
};
use super::{events::VoiceEvents, Sink, VoiceGatewayMesssage};
use super::{events::VoiceEvents, Sink, VoiceGatewayMessage};
/// Represents a handle to a Voice Gateway connection.
/// 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 message = VoiceGatewayMesssage(payload_json);
let message = VoiceGatewayMessage(payload_json);
self.websocket_send
.lock()

View File

@ -11,7 +11,7 @@ use tokio::sync::{mpsc::Sender, Mutex};
use crate::{
gateway::heartbeat::HEARTBEAT_ACK_TIMEOUT,
types::{VoiceGatewaySendPayload, VOICE_HEARTBEAT, VOICE_HEARTBEAT_ACK},
voice::gateway::VoiceGatewayMesssage,
voice::gateway::VoiceGatewayMessage,
};
use super::Sink;
@ -133,7 +133,7 @@ impl VoiceHeartbeatHandler {
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;
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].
/// This struct is used internally when handling messages.
#[derive(Clone, Debug)]
pub struct VoiceGatewayMesssage(pub String);
pub struct VoiceGatewayMessage(pub String);
impl VoiceGatewayMesssage {
impl VoiceGatewayMessage {
/// Parses the message as an error;
/// Returns the error if succesfully parsed, None if the message isn't an error
pub fn error(&self) -> Option<VoiceGatewayError> {
@ -34,6 +34,6 @@ impl VoiceGatewayMesssage {
/// Parses the message as a payload;
/// Returns a result of deserializing
pub fn payload(&self) -> Result<VoiceGatewayReceivePayload, serde_json::Error> {
return serde_json::from_str(&self.0);
serde_json::from_str(&self.0)
}
}