Skip to content

Commit

Permalink
Update websocket.rs
Browse files Browse the repository at this point in the history
  • Loading branch information
DamienDeepgram authored Jan 23, 2025
1 parent 73e5385 commit 2d703c1
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions src/listen/websocket.rs
Original file line number Diff line number Diff line change
Expand Up @@ -369,10 +369,14 @@ impl<'a> WebsocketBuilder<'a> {
let mut handle = handle;
let mut tx = tx;
let mut stream = stream;

let mut ws_stream_recv = ws_stream_recv.fuse();
let mut message_rx = message_rx.fuse();

loop {
select_biased! {
// Receiving messages from WebsocketHandle
response = handle.receive().fuse() => {
response = ws_stream_recv.next() => {
// eprintln!("<stream> got response");
match response {
Some(Ok(response)) if matches!(response, StreamResponse::TerminalResponse { .. }) => {
Expand All @@ -397,7 +401,7 @@ impl<'a> WebsocketBuilder<'a> {
}
}
// Receiving audio data from stream.
chunk = stream.next().fuse() => {
chunk = message_rx.next() => {
match chunk {
Some(Ok(audio)) => if let Err(err) = handle.send_data(audio.to_vec()).await {
// eprintln!("<stream> got audio");
Expand Down

0 comments on commit 2d703c1

Please sign in to comment.