try conn
This commit is contained in:
parent
a1b29106ad
commit
229211689a
1 changed files with 9 additions and 5 deletions
10
src/lib.rs
10
src/lib.rs
|
@ -18,10 +18,14 @@ pub struct QuadWs {
|
|||
channel: WsChannnel,
|
||||
}
|
||||
impl QuadWs {
|
||||
pub fn new(url: String) -> Self {
|
||||
Self {
|
||||
channel: ws_open_rust(url).unwrap()
|
||||
pub fn new(url: String) -> Option<Self> {
|
||||
let conn = ws_open_rust(url);
|
||||
if conn.is_none() {
|
||||
return None;
|
||||
}
|
||||
Some(Self {
|
||||
channel: conn.unwrap(),
|
||||
})
|
||||
}
|
||||
pub fn write(&mut self, data: Vec<u8>) -> bool {
|
||||
ws_write_rust(&mut self.channel, data)
|
||||
|
|
Loading…
Reference in a new issue