Read frame.
This commit is contained in:
parent
7ee1a91549
commit
8082e5d000
@ -18,8 +18,19 @@ impl MpvFramed {
|
||||
pub async fn read_frame(
|
||||
&mut self,
|
||||
) -> Result<Option<serde_json::Value>, Box<dyn std::error::Error>> {
|
||||
//
|
||||
todo!()
|
||||
loop {
|
||||
if let Some(frame) = self.parse_frame()? {
|
||||
return Ok(Some(frame));
|
||||
}
|
||||
|
||||
if 0 == self.socket_read.read_buf(&mut self.buffer).await? {
|
||||
if self.buffer.is_empty() {
|
||||
return Ok(None);
|
||||
} else {
|
||||
return Err("connection reset by peer".into());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fn parse_frame(&mut self) -> Result<Option<serde_json::Value>, Box<dyn std::error::Error>> {
|
||||
|
Loading…
x
Reference in New Issue
Block a user