pub struct RpcServer<Context> { /* private fields */ }Expand description
RpcServer receives and process different requests from the RpcClient
Once a RpcServer is inited, you should attach a transport and handler for the port creation.
Implementations§
source§impl<Context: Send + Sync + 'static> RpcServer<Context>
impl<Context: Send + Sync + 'static> RpcServer<Context>
pub fn create(ctx: Context) -> Self
sourcepub fn get_server_events_sender(&self) -> ServerEventsSender
pub fn get_server_events_sender(&self) -> ServerEventsSender
Get a ServerEventsSender to send allowed server events from outside
sourcepub fn attach_transport<T: Transport + Send + Sync + 'static>(
&mut self,
transport: T
) -> ServerResult<()>
pub fn attach_transport<T: Transport + Send + Sync + 'static>( &mut self, transport: T ) -> ServerResult<()>
Attaches the server half of the transport for Client<>Server communications
It differs from sending the ServerEvents::AtacchTransport because it can only be used to attach transport from the current thread where the RpcServer was initalized due to the mutably borrow
sourcepub async fn run(&mut self)
pub async fn run(&mut self)
Start processing ServerEvent events and listening on a channel for new TransportNotification that are sent by all the attached transports that are running in background tasks.
sourcepub fn set_handler<H>(&mut self, handler: H)where
H: Fn(&mut RpcServerPort<Context>) + Send + Sync + 'static,
pub fn set_handler<H>(&mut self, handler: H)where H: Fn(&mut RpcServerPort<Context>) + Send + Sync + 'static,
Set a handler for the port creation
When a port is created, a service should be registered for the port.