fn handle_platform_message(&self, mut msg: PlatformMessage) {
        debug_assert_eq!(msg.channel, self.name());
        if let Some(handler) = self.method_handler() {
            if let Some(engine) = self.engine() {
                let call = self.codec().decode_method_call(msg.message).unwrap();
                let channel = self.name().to_owned();
                log::trace!(
                    "on channel {}, got method call {} with args {:?}",
                    channel,
                    call.method,
                    call.args
                );
                let plugin_name = self.plugin_name();
                let mut response_handle = msg.response_handle.take();
                let codec = self.codec();

                engine.clone().run_in_background(async move {
                    let mut handler = handler.write().unwrap();
                    let method = call.method.clone();
                    let result = handler.on_method_call(call, engine.clone());
                    let response = match result {
                        Ok(value) => MethodCallResult::Ok(value),
                        Err(MethodCallError::NotImplemented) => {
                            let target = handler.log_target().unwrap_or(plugin_name);
                            log::info!(
                                target: target,
                                "method call {}#{} is unimplemented.",
                                channel,
                                method
                            );
                            MethodCallError::NotImplemented.into()
                        }
                        Err(error) => {
                            let target = handler.log_target().unwrap_or(plugin_name);
                            log::error!(
                                target: target,
                                "error in method call {}#{}: {}",
                                channel,
                                method,
                                error
                            );
                            error.into()
                        }
                    };
                    engine.post_platform_callback(crate::MainThreadCallback::Channel((
                        channel,
                        Box::new(move |channel| {
                            let buf = codec.encode_method_call_response(&response);
                            if let Some(handle) = response_handle.take() {
                                channel.send_response(handle, &buf);
                            }
                        }),
                    )));
                });
            }
        }
    }
/// Handle incoming message received on this channel
Handle incoming message received on this channel
Handle incoming message received on this channel
fn handle_platform_message(&self, mut msg: PlatformMessage) {
        debug_assert_eq!(msg.channel, self.name());
        if let Some(handler) = self.method_handler() {
            if let Some(engine) = self.engine() {
                let call = self.codec().decode_method_call(msg.message).unwrap();
                let channel = self.name().to_owned();
                log::trace!(
                    "on channel {}, got method call {} with args {:?}",
                    channel,
                    call.method,
                    call.args
                );
                let plugin_name = self.plugin_name();
                let mut response_handle = msg.response_handle.take();
                let codec = self.codec();
                engine.clone().run_in_background(async move {
                    let mut handler = handler.write().unwrap();
                    let method = call.method.clone();
                    let result = handler.on_method_call(call, engine.clone());
                    let response = match result {
                        Ok(value) => MethodCallResult::Ok(value),
                        Err(MethodCallError::NotImplemented) => {
                            let target = handler.log_target().unwrap_or(plugin_name);
                            log::info!(
                                target: target,
                                "method call {}#{} is unimplemented.",
                                channel,
                                method
                            );
                            MethodCallError::NotImplemented.into()
                        }
                        Err(error) => {
                            let target = handler.log_target().unwrap_or(plugin_name);
                            log::error!(
                                target: target,
                                "error in method call {}#{}: {}",
                                channel,
                                method,
                                error
                            );
                            error.into()
                        }
                    };
                    engine.post_platform_callback(crate::MainThreadCallback::Channel((
                        channel,
                        Box::new(move |channel| {
                            let buf = codec.encode_method_call_response(&response);
                            if let Some(handle) = response_handle.take() {
                                channel.send_response(handle, &buf);
                            }
                        }),
                    )));
                });
            }
        }
    }
fn handle_platform_message ( & self , mut msg : PlatformMessage ) { debug_assert_eq ! ( msg channel self name ( ) ) ; if let Some ( handler ) = self . method_handler ( ) { if let Some ( engine ) = self . engine ( ) { let call = self . codec ( ) . decode_method_call ( msg . message ) . unwrap ( ) ; let channel = self . name ( ) . to_owned ( ) ; log :: trace ! ( " " channel call method call args ) ; let plugin_name = self . plugin_name ( ) ; let mut response_handle = msg . response_handle . take ( ) ; let codec = self . codec ( ) ; engine . clone ( ) . run_in_background ( async move { let mut handler = handler . write ( ) . unwrap ( ) ; let method = call . method . clone ( ) ; let result = handler . on_method_call ( call , engine . clone ( ) ) ; let response = match result { Ok ( value ) => MethodCallResult :: Ok ( value ) , Err ( MethodCallError :: NotImplemented ) => { let target = handler . log_target ( ) . unwrap_or ( plugin_name ) ; log :: info ! ( target target " " channel method ) ; MethodCallError :: NotImplemented . into ( ) } Err ( error ) => { let target = handler . log_target ( ) . unwrap_or ( plugin_name ) ; log :: error ! ( target target " " channel method error ) ; error . into ( ) } } ; engine . post_platform_callback ( crate :: MainThreadCallback :: Channel ( ( channel , Box :: new ( move | channel | { let buf = codec . encode_method_call_response ( & response ) ; if let Some ( handle ) = response_handle . take ( ) { channel . send_response ( handle , & buf ) ; } } ) , ) ) ) ; } ) ; } } }
Handle incoming message received on this channel
Handle incoming message received on this channel
&self
msg
PlatformMessage