-
Notifications
You must be signed in to change notification settings - Fork 80
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor: Added hotfix for issue 133
- Loading branch information
Showing
1 changed file
with
21 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -9,13 +9,17 @@ use std::borrow::Cow; | |
use std::convert::TryFrom; | ||
use std::str::from_utf8; | ||
use std::sync::{Arc, Mutex, RwLock}; | ||
use std::thread::sleep; | ||
use std::time::Duration; | ||
use websocket::WebSocketError; | ||
use websocket::{ | ||
client::sync::Client as WsClient, | ||
client::Url, | ||
dataframe::DataFrame, | ||
dataframe::Opcode, | ||
header::Headers, | ||
sync::stream::{TcpStream, TlsStream}, | ||
ws::dataframe::DataFrame, | ||
ws::dataframe::DataFrame as DataFrameable, | ||
ClientBuilder as WsClientBuilder, Message, | ||
}; | ||
|
||
|
@@ -96,11 +100,24 @@ impl Transport for WebsocketSecureTransport { | |
} | ||
|
||
fn poll(&self) -> Result<Bytes> { | ||
let mut receiver = self.client.lock()?; | ||
let received_df: DataFrame; | ||
loop { | ||
let mut receiver = self.client.lock()?; | ||
receiver.set_nonblocking(true)?; | ||
match receiver.recv_dataframe() { | ||
Ok(payload) => { | ||
received_df = payload; | ||
break; | ||
} | ||
Err(WebSocketError::Other(_)) => (), | ||
This comment has been minimized.
Sorry, something went wrong.
This comment has been minimized.
Sorry, something went wrong.
1c3t3a
Author
Owner
|
||
Err(err) => return Err(err.into()), | ||
} | ||
receiver.set_nonblocking(false)?; | ||
drop(receiver); | ||
sleep(Duration::from_millis(200)); | ||
} | ||
|
||
// if this is a binary payload, we mark it as a message | ||
let received_df = receiver.recv_dataframe()?; | ||
drop(receiver); | ||
match received_df.opcode { | ||
Opcode::Binary => { | ||
let mut message = BytesMut::with_capacity(received_df.data.len() + 1); | ||
|
Why is this error silenced @1c3t3a ? Consider adding at least a log statement.