fixes
This commit is contained in:
parent
7bf1e76329
commit
78b057e0ef
3 changed files with 5 additions and 5 deletions
|
@ -70,7 +70,7 @@ function ws_write(id, ptr, len) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
function ws_available(id) {
|
function ws_available(id) {
|
||||||
if (ws[id].received.length == 0) return -1;
|
if (ws[id] != null || ws[id].received.length == 0) return -1;
|
||||||
return ws[id].received[0].length;
|
return ws[id].received[0].length;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -24,8 +24,8 @@ impl QuadWs {
|
||||||
channel: ws_open_rust(url).unwrap(),
|
channel: ws_open_rust(url).unwrap(),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
pub fn write(&mut self) -> bool {
|
pub fn write(&mut self, data: Vec<u8>) -> bool {
|
||||||
ws_write_rust(&mut self.channel, vec![])
|
ws_write_rust(&mut self.channel, data)
|
||||||
}
|
}
|
||||||
pub fn close(&mut self) {
|
pub fn close(&mut self) {
|
||||||
ws_close_rust(&mut self.channel)
|
ws_close_rust(&mut self.channel)
|
||||||
|
|
|
@ -32,8 +32,8 @@ pub fn ws_read_rust(socket: &mut WsChannnel) -> Option<Vec<u8>> {
|
||||||
if available < 0 {
|
if available < 0 {
|
||||||
return None;
|
return None;
|
||||||
}
|
}
|
||||||
let mut buffer = vec![0; available as usize];
|
let buffer = vec![0; available as usize];
|
||||||
unsafe { ws_read(*socket, buffer.as_mut_ptr(), available as u32) };
|
unsafe { ws_read(*socket, buffer.as_ptr(), available as u32) };
|
||||||
return Some(buffer);
|
return Some(buffer);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue