Struct reactive_messaging::SocketClient
source · pub struct SocketClient<const BUFFERED_MESSAGES_PER_PEER_COUNT: usize> { /* private fields */ }
Expand description
The handle to define, start and shutdown a Reactive Client for Socket Connections
BUFFERED_MESSAGES_PER_PEER_COUNT
is the number of messages that may be produced ahead of sending (to the server)
as well as the number of messages that this client may accumulate from the server before denying new ones
Implementations§
source§impl<const BUFFERED_MESSAGES_PER_PEER_COUNT: usize> SocketClient<BUFFERED_MESSAGES_PER_PEER_COUNT>
impl<const BUFFERED_MESSAGES_PER_PEER_COUNT: usize> SocketClient<BUFFERED_MESSAGES_PER_PEER_COUNT>
sourcepub async fn spawn_responsive_processor<ServerMessages: ReactiveMessagingDeserializer<ServerMessages> + Send + Sync + PartialEq + Debug + 'static, ClientMessages: ReactiveMessagingSerializer<ClientMessages> + ResponsiveMessages<ClientMessages> + Send + Sync + PartialEq + Debug + 'static, ConnectionEventsCallbackFuture: Future<Output = ()> + Send, ClientStreamType: Stream<Item = ClientMessages> + Send + 'static, IntoString: Into<String>>(
ip: IntoString,
port: u16,
connection_events_callback: impl Fn(ConnectionEvent<BUFFERED_MESSAGES_PER_PEER_COUNT, ClientMessages>) -> ConnectionEventsCallbackFuture + Send + Sync + 'static,
processor_stream_builder: impl Fn(String, u16, Arc<Peer<BUFFERED_MESSAGES_PER_PEER_COUNT, ClientMessages>>, ProcessorRemoteStreamType<BUFFERED_MESSAGES_PER_PEER_COUNT, ServerMessages>) -> ClientStreamType + Send + Sync + 'static
) -> Result<Self, Box<dyn Error + Sync + Send>>
pub async fn spawn_responsive_processor<ServerMessages: ReactiveMessagingDeserializer<ServerMessages> + Send + Sync + PartialEq + Debug + 'static, ClientMessages: ReactiveMessagingSerializer<ClientMessages> + ResponsiveMessages<ClientMessages> + Send + Sync + PartialEq + Debug + 'static, ConnectionEventsCallbackFuture: Future<Output = ()> + Send, ClientStreamType: Stream<Item = ClientMessages> + Send + 'static, IntoString: Into<String>>( ip: IntoString, port: u16, connection_events_callback: impl Fn(ConnectionEvent<BUFFERED_MESSAGES_PER_PEER_COUNT, ClientMessages>) -> ConnectionEventsCallbackFuture + Send + Sync + 'static, processor_stream_builder: impl Fn(String, u16, Arc<Peer<BUFFERED_MESSAGES_PER_PEER_COUNT, ClientMessages>>, ProcessorRemoteStreamType<BUFFERED_MESSAGES_PER_PEER_COUNT, ServerMessages>) -> ClientStreamType + Send + Sync + 'static ) -> Result<Self, Box<dyn Error + Sync + Send>>
Spawns a task to connect to the server @ ip
& port
and returns, immediately,
an object through which the caller may inquire some stats (if opted in) and request
the client to disconnect.
The given dialog_processor
will produce non-futures & non-fallibles ClientMessages
that will be sent to the server.
sourcepub async fn spawn_unresponsive_processor<ServerMessages: ReactiveMessagingDeserializer<ServerMessages> + Send + Sync + PartialEq + Debug + 'static, ClientMessages: ReactiveMessagingSerializer<ClientMessages> + Send + Sync + PartialEq + Debug + 'static, OutputStreamItemsType: Send + Sync + Debug + 'static, OutputStreamType: Stream<Item = OutputStreamItemsType> + Send + 'static, ConnectionEventsCallbackFuture: Future<Output = ()> + Send, IntoString: Into<String>>(
ip: IntoString,
port: u16,
connection_events_callback: impl Fn(ConnectionEvent<BUFFERED_MESSAGES_PER_PEER_COUNT, ClientMessages>) -> ConnectionEventsCallbackFuture + Send + Sync + 'static,
processor_stream_builder: impl Fn(String, u16, Arc<Peer<BUFFERED_MESSAGES_PER_PEER_COUNT, ClientMessages>>, ProcessorRemoteStreamType<BUFFERED_MESSAGES_PER_PEER_COUNT, ServerMessages>) -> OutputStreamType + Send + Sync + 'static
) -> Result<Self, Box<dyn Error + Sync + Send>>
pub async fn spawn_unresponsive_processor<ServerMessages: ReactiveMessagingDeserializer<ServerMessages> + Send + Sync + PartialEq + Debug + 'static, ClientMessages: ReactiveMessagingSerializer<ClientMessages> + Send + Sync + PartialEq + Debug + 'static, OutputStreamItemsType: Send + Sync + Debug + 'static, OutputStreamType: Stream<Item = OutputStreamItemsType> + Send + 'static, ConnectionEventsCallbackFuture: Future<Output = ()> + Send, IntoString: Into<String>>( ip: IntoString, port: u16, connection_events_callback: impl Fn(ConnectionEvent<BUFFERED_MESSAGES_PER_PEER_COUNT, ClientMessages>) -> ConnectionEventsCallbackFuture + Send + Sync + 'static, processor_stream_builder: impl Fn(String, u16, Arc<Peer<BUFFERED_MESSAGES_PER_PEER_COUNT, ClientMessages>>, ProcessorRemoteStreamType<BUFFERED_MESSAGES_PER_PEER_COUNT, ServerMessages>) -> OutputStreamType + Send + Sync + 'static ) -> Result<Self, Box<dyn Error + Sync + Send>>
Spawns a task to connect to the server @ ip
& port
and returns, immediately,
an object through which the caller may inquire some stats (if opted in) and request
the client to disconnect.
The given dialog_processor
will produce non-futures & non-fallibles items that won’t be sent to the server
– if you want the processor to produce “answer messages” to the server, see SocketClient::spawn_responsive_processor().