Struct dcl_rpc::messages_handlers::ServerMessagesHandler
source · pub struct ServerMessagesHandler {
pub streams_handler: Arc<StreamsHandler>,
/* private fields */
}Expand description
It’s in charge of handling every request that the client sends
It spawns a background tasks to process every request
Fields§
§streams_handler: Arc<StreamsHandler>Data structure in charge of handling all messages related to streams
Implementations§
source§impl ServerMessagesHandler
impl ServerMessagesHandler
pub fn new() -> Self
sourcepub fn process_unary_request(
&self,
transport: Arc<dyn Transport + Send + Sync>,
message_identifier: u32,
procedure_handler: UnaryResponse
)
pub fn process_unary_request( &self, transport: Arc<dyn Transport + Send + Sync>, message_identifier: u32, procedure_handler: UnaryResponse )
Receive a unary procedure handler returned future and process it in a spawned background task.
This function aims to run the procedure handler in spawned task to achieve processing requests concurrently.
sourcepub fn process_server_streams_request(
self: Arc<Self>,
transport: Arc<dyn Transport + Send + Sync>,
message_identifier: u32,
port_id: u32,
procedure_handler: ServerStreamsResponse
)
pub fn process_server_streams_request( self: Arc<Self>, transport: Arc<dyn Transport + Send + Sync>, message_identifier: u32, port_id: u32, procedure_handler: ServerStreamsResponse )
Receive a server streams procedure handler returned future and process it in a spawned background task.
This function aims to run the procedure handler in spawned task to achieve processing requests concurrently.
sourcepub fn process_client_streams_request(
self: Arc<Self>,
transport: Arc<dyn Transport + Send + Sync>,
message_identifier: u32,
client_stream_id: u32,
procedure_handler: ClientStreamsResponse,
listener: AsyncChannelSender<(RpcMessageTypes, u32, StreamMessage)>
)
pub fn process_client_streams_request( self: Arc<Self>, transport: Arc<dyn Transport + Send + Sync>, message_identifier: u32, client_stream_id: u32, procedure_handler: ClientStreamsResponse, listener: AsyncChannelSender<(RpcMessageTypes, u32, StreamMessage)> )
Receive a client streams procedure handler returned future and process it in a spawned background task.
This function aims to run the procedure handler in spawned task to achieve processing requests concurrently.
sourcepub fn process_bidir_streams_request(
self: Arc<Self>,
transport: Arc<dyn Transport + Send + Sync>,
message_identifier: u32,
port_id: u32,
client_stream_id: u32,
listener: AsyncChannelSender<(RpcMessageTypes, u32, StreamMessage)>,
procedure_handler: BiStreamsResponse
)
pub fn process_bidir_streams_request( self: Arc<Self>, transport: Arc<dyn Transport + Send + Sync>, message_identifier: u32, port_id: u32, client_stream_id: u32, listener: AsyncChannelSender<(RpcMessageTypes, u32, StreamMessage)>, procedure_handler: BiStreamsResponse )
Receive a bidirectional streams procedure handler returned future and process it in a spawned background task.
This function aims to run the procedure handler in spawned task to achieve processing requests concurrently.
sourcepub fn notify_new_client_stream(
self: Arc<Self>,
message_identifier: u32,
payload: Vec<u8>
)
pub fn notify_new_client_stream( self: Arc<Self>, message_identifier: u32, payload: Vec<u8> )
Notify the listener for a client streams procedure that the client sent a new StreamMessage
This function aims to run the procedure handler in spawned task to achieve processing requests concurrently.
sourcepub async fn send_response(
&self,
transport: Arc<dyn Transport + Send + Sync>,
message_identifier: u32,
payload: Vec<u8>
)
pub async fn send_response( &self, transport: Arc<dyn Transport + Send + Sync>, message_identifier: u32, payload: Vec<u8> )
Sends a common response Response through the given transport
sourcepub async fn register_listener(
&self,
message_id: u32,
callback: AsyncChannelSender<(RpcMessageTypes, u32, StreamMessage)>
)
pub async fn register_listener( &self, message_id: u32, callback: AsyncChannelSender<(RpcMessageTypes, u32, StreamMessage)> )
Register a listener for a specific message_id used for client and bidirectional streams
sourcepub async fn unregister_listener(&self, message_id: u32)
pub async fn unregister_listener(&self, message_id: u32)
Unregister a listener for a specific message_id used for client and bidirectional streams