Skip to content

Commit

Permalink
clean up
Browse files Browse the repository at this point in the history
  • Loading branch information
shenjackyuanjie committed Apr 11, 2024
1 parent d681f57 commit 31f0fe3
Showing 1 changed file with 4 additions and 11 deletions.
15 changes: 4 additions & 11 deletions socketio/src/client/raw_client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -295,10 +295,6 @@ impl RawClient {
}
// nope, just ignore it, the official implment just remove the ack id when timeout
// https://github.com/socketio/socket.io-client/blob/main/lib/socket.ts#L467-L495
// } else {
// // Do something with timed out acks?
// }

false
});

Expand Down Expand Up @@ -337,16 +333,13 @@ impl RawClient {
if let Ok(Value::Array(contents)) = serde_json::from_str::<Value>(data) {
let (event, payloads) = match contents.len() {
0 => return Err(Error::IncompletePacket()),
1 => {
(
Event::Message,
contents.as_slice(), // safe to unwrap, checked above
)
}
1 => (Event::Message, contents.as_slice()),
// get rest of data if first is a event
_ => match contents.first() {
// get rest of data if first is a event
Some(Value::String(ev)) => (Event::from(ev.as_str()), &contents[1..]),
// get rest(1..) of them as data, not just take the 2nd element
_ => (Event::Message, contents.as_slice()),
// take them all as data
},
};

Expand Down

0 comments on commit 31f0fe3

Please sign in to comment.