// 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?
letobj=match&frame{
serde_json::Value::Object(obj)=>obj,
_=>{
returnErr("Got back a json value that wasn't an object.".into());
}
};
matchobj.get("event"){
Some(orig@serde_json::Value::String(s))=>{
println!("Notifying listeners for event {}",s);
letlisteners={
letdb_handle=event_listeners.lock().unwrap();
match(*db_handle).get(s){
None=>Vec::new(),
Some(listeners)=>listeners.to_owned(),
}
};
forlistenerinlisteners{
listener.send(frame.clone()).await;
}
}
_=>returnErr("Event with no string value".into()),
};
returnOk(());
}
// get the request id and push the result into the channel
@ -99,10 +129,6 @@ impl MpvCtl {
returnErr("Got back a json value that wasn't an object.".into());