Skip to content

Commit

Permalink
fix: some errors in vgw
Browse files Browse the repository at this point in the history
  • Loading branch information
kozabrada123 committed Oct 28, 2024
1 parent 0c79ddc commit c9dbaac
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions src/voice/gateway/gateway.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,10 @@ use crate::{

use super::{events::VoiceEvents, heartbeat::VoiceHeartbeatHandler, VoiceGatewayHandle};

// Needed to observe close codes
#[cfg(target_arch = "wasm32")]
use pharos::Observable;

#[derive(Debug)]
pub struct VoiceGateway {
events: Arc<Mutex<VoiceEvents>>,
Expand Down Expand Up @@ -82,7 +86,7 @@ impl VoiceGateway {
};

#[cfg(target_arch = "wasm32")]
let msg: VoiceGatewayMessage = websocket_receive.next().await.unwrap().into();
let msg: VoiceGatewayMessage = websocket_receive.0.next().await.unwrap().into();
let gateway_payload: VoiceGatewayReceivePayload = serde_json::from_str(&msg.0).unwrap();

if gateway_payload.op_code != VOICE_HELLO {
Expand Down Expand Up @@ -203,7 +207,7 @@ impl VoiceGateway {
if let Some(event) = maybe_event {
match event {
ws_stream_wasm::WsEvent::Closed(closed_event) => {
let close_code = VoiceCloseCode::try_from(closed_event.code).unwrap_or(VoiceCloseCode::UnknownError);
let close_code = VoiceCloseCode::try_from(closed_event.code).unwrap_or(VoiceCloseCode::FailedToDecodePayload);
self.handle_close_code(close_code).await;
break;
}
Expand Down

0 comments on commit c9dbaac

Please sign in to comment.