Runnable

Trait Runnable 

Source
pub trait Runnable {
    // Required methods
    fn on_init(&mut self, cid: &rsm_component_t);
    fn on_timer(
        &mut self,
        cid: &rsm_component_t,
        timer_id: rsm_timer_id_t,
        timer_data: usize,
    );
    fn on_socket_event(
        &mut self,
        cid: &rsm_component_t,
        event: rsm_socket_event_t,
    );
    fn on_message(
        &mut self,
        cid: &rsm_component_t,
        msg_id: rsm_message_id_t,
        msg: &rsm_message_t,
    );
    fn is_inited(&self) -> bool;
    fn on_close(&mut self, cid: &rsm_component_t);
}
Expand description

Component must implement the Runnable Trait

Required Methods§

Source

fn on_init(&mut self, cid: &rsm_component_t)

task init, called first when the task instance is created

Source

fn on_timer( &mut self, cid: &rsm_component_t, timer_id: rsm_timer_id_t, timer_data: usize, )

called when a timer expiry event occured, timer_id indicate which timer fired

Source

fn on_socket_event(&mut self, cid: &rsm_component_t, event: rsm_socket_event_t)

socket event, if the task use rsm socket to send/recv message upon recv this message, task should use correspondant Upd/Tcp/Raw Socket to recv packet, util no more packet rsm automatically accept the tcp connection request from client, the notify the app, app can close the socket to reject the connection

Source

fn on_message( &mut self, cid: &rsm_component_t, msg_id: rsm_message_id_t, msg: &rsm_message_t, )

an ordinary message received, the app should call msg.decode method to get original data structure

Source

fn is_inited(&self) -> bool

Source

fn on_close(&mut self, cid: &rsm_component_t)

task has been destroyed, reserved for future use

Implementors§