plugin_framework, debug listen event

Signed-off-by: fufesou <shuanglongchen@yeah.net>
This commit is contained in:
fufesou 2023-04-27 14:41:53 +08:00
parent 9a457894b3
commit 12ab0a433a
4 changed files with 28 additions and 17 deletions

View File

@ -260,10 +260,15 @@ class PluginItem extends StatelessWidget {
String? _getOption(OptionModel model, String key) {
var v = model.value;
if (v == null) {
if (peerId.isEmpty) {
v = bind.pluginGetSharedOption(id: pluginId, key: key);
} else {
v = bind.pluginGetSessionOption(id: pluginId, peer: peerId, key: key);
try {
if (peerId.isEmpty) {
v = bind.pluginGetSharedOption(id: pluginId, key: key);
} else {
v = bind.pluginGetSessionOption(id: pluginId, peer: peerId, key: key);
}
} catch (e) {
debugPrint('Failed to get option "$key", $e');
v = null;
}
}
return v;

View File

@ -965,10 +965,12 @@ impl<T: InvokeUiSession> Remote<T> {
// on connection established client
#[cfg(all(feature = "flutter", feature = "plugin_framework"))]
#[cfg(not(any(target_os = "android", target_os = "ios")))]
crate::plugin::handle_listen_event(
crate::plugin::EVENT_ON_CONN_CLIENT,
&self.handler.id,
);
{
crate::plugin::handle_listen_event(
crate::plugin::EVENT_ON_CONN_CLIENT.to_owned(),
self.handler.id.clone(),
)
}
}
if self.handler.is_file_transfer() {

View File

@ -422,8 +422,7 @@ pub fn handle_server_event(id: &str, peer: &str, event: &[u8]) -> ResultType<()>
handle_event(METHOD_HANDLE_PEER, id, peer, event)
}
#[inline]
pub fn handle_listen_event(event: &str, peer: &str) {
fn _handle_listen_event(event: String, peer: String) {
let mut plugins = Vec::new();
for info in PLUGIN_INFO.read().unwrap().values() {
if info.desc.listen_events().contains(&event.to_string()) {
@ -435,9 +434,7 @@ pub fn handle_listen_event(event: &str, peer: &str) {
return;
}
if let Ok(mut evt) = serde_json::to_string(&MsgListenEvent {
event: event.to_string(),
}) {
if let Ok(mut evt) = serde_json::to_string(&MsgListenEvent { event }) {
let mut evt_bytes = evt.as_bytes().to_vec();
evt_bytes.push(0);
let mut peer: String = peer.to_owned();
@ -471,6 +468,11 @@ pub fn handle_listen_event(event: &str, peer: &str) {
}
}
#[inline]
pub fn handle_listen_event(event: String, peer: String) {
std::thread::spawn(|| _handle_listen_event(event, peer));
}
#[inline]
pub fn handle_client_event(id: &str, peer: &str, event: &[u8]) -> Message {
let mut peer: String = peer.to_owned();

View File

@ -565,10 +565,12 @@ impl Connection {
}
#[cfg(all(feature = "flutter", feature = "plugin_framework"))]
#[cfg(not(any(target_os = "android", target_os = "ios")))]
crate::plugin::handle_listen_event(
crate::plugin::EVENT_ON_CONN_CLOSE_SERVER,
&conn.lr.my_id,
);
{
crate::plugin::handle_listen_event(
crate::plugin::EVENT_ON_CONN_CLOSE_SERVER.to_owned(),
conn.lr.my_id.clone(),
);
}
video_service::notify_video_frame_fetched(id, None);
scrap::codec::Encoder::update(id, scrap::codec::EncodingUpdate::Remove);
video_service::VIDEO_QOS.lock().unwrap().reset();