Struct reactive_messaging::SocketClient
source · pub struct SocketClient { /* private fields */ }Expand description
The handle to define, start and shutdown a Reactive Client for Socket Connections
Implementations§
source§impl SocketClient
impl SocketClient
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<ClientMessages>) -> ConnectionEventsCallbackFuture + Send + Sync + 'static,
processor_stream_builder: impl Fn(String, u16, Arc<Peer<ClientMessages>>, ProcessorRemoteStreamType<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<ClientMessages>) -> ConnectionEventsCallbackFuture + Send + Sync + 'static, processor_stream_builder: impl Fn(String, u16, Arc<Peer<ClientMessages>>, ProcessorRemoteStreamType<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<ClientMessages>) -> ConnectionEventsCallbackFuture + Send + Sync + 'static,
processor_stream_builder: impl Fn(String, u16, Arc<Peer<ClientMessages>>, ProcessorRemoteStreamType<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<ClientMessages>) -> ConnectionEventsCallbackFuture + Send + Sync + 'static, processor_stream_builder: impl Fn(String, u16, Arc<Peer<ClientMessages>>, ProcessorRemoteStreamType<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().