This commit is contained in:
jusax23 2023-10-02 00:39:51 +02:00
parent 7bf1e76329
commit 78b057e0ef
Signed by: jusax23
GPG key ID: 499E2AA870C1CD41
3 changed files with 5 additions and 5 deletions

View file

@ -70,7 +70,7 @@ function ws_write(id, ptr, len) {
return false;
}
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;
}

View file

@ -24,8 +24,8 @@ impl QuadWs {
channel: ws_open_rust(url).unwrap(),
}
}
pub fn write(&mut self) -> bool {
ws_write_rust(&mut self.channel, vec![])
pub fn write(&mut self, data: Vec<u8>) -> bool {
ws_write_rust(&mut self.channel, data)
}
pub fn close(&mut self) {
ws_close_rust(&mut self.channel)

View file

@ -32,8 +32,8 @@ pub fn ws_read_rust(socket: &mut WsChannnel) -> Option<Vec<u8>> {
if available < 0 {
return None;
}
let mut buffer = vec![0; available as usize];
unsafe { ws_read(*socket, buffer.as_mut_ptr(), available as u32) };
let buffer = vec![0; available as usize];
unsafe { ws_read(*socket, buffer.as_ptr(), available as u32) };
return Some(buffer);
}