Detect events.
This commit is contained in:
parent
e85f9d3d41
commit
4dc352714c
@ -56,6 +56,15 @@ impl MpvCtl {
|
||||
match framed_read.read_frame().await {
|
||||
Ok(Some(frame)) => {
|
||||
println!("Read {}", frame);
|
||||
// check if its an event
|
||||
let is_event = match &frame {
|
||||
serde_json::Value::Object(obj) => obj.contains_key("event"),
|
||||
_ => false,
|
||||
};
|
||||
if is_event {
|
||||
// TODO: Currently we are not doing anything with events. Perhaps they should be dumped onto a stream? Perhaps many streams each representing a listener to an event?
|
||||
return Ok(());
|
||||
}
|
||||
// get the request id and push the result into the channel
|
||||
let reqid = {
|
||||
let obj = match &frame {
|
||||
@ -64,6 +73,10 @@ impl MpvCtl {
|
||||
return Err("Got back a json value that wasn't an object.".into());
|
||||
}
|
||||
};
|
||||
match obj.get("event") {
|
||||
Some(event) => {}
|
||||
_ => (),
|
||||
};
|
||||
match obj.get("request_id") {
|
||||
Some(serde_json::Value::Number(reqid)) if reqid.is_u64() => {
|
||||
reqid.as_u64().unwrap()
|
||||
|
Loading…
x
Reference in New Issue
Block a user