pub struct UseWebSocketOptions<Rx, E, D, Hb, HbCodec>where
Rx: ?Sized,
Hb: Default + Send + Sync + 'static,
HbCodec: Encoder<Hb> + HybridEncoder<Hb, <HbCodec as Encoder<Hb>>::Encoded, Error = <HbCodec as Encoder<Hb>>::Error>,{ /* private fields */ }
Expand description
Options for use_websocket_with_options
.
Implementations§
Source§impl<Rx, E, D, Hb, HbCodec> UseWebSocketOptions<Rx, E, D, Hb, HbCodec>
impl<Rx, E, D, Hb, HbCodec> UseWebSocketOptions<Rx, E, D, Hb, HbCodec>
Sourcepub fn on_open(self, value: impl Fn(Event) + Send + Sync + 'static) -> Self
pub fn on_open(self, value: impl Fn(Event) + Send + Sync + 'static) -> Self
WebSocket
connect callback.
Sourcepub fn on_message_raw(
self,
value: impl Fn(&str) + Send + Sync + 'static,
) -> Self
pub fn on_message_raw( self, value: impl Fn(&str) + Send + Sync + 'static, ) -> Self
WebSocket
message callback for text.
Sourcepub fn on_message_raw_bytes(
self,
value: Arc<dyn Fn(&[u8]) + Send + Sync>,
) -> Self
pub fn on_message_raw_bytes( self, value: Arc<dyn Fn(&[u8]) + Send + Sync>, ) -> Self
WebSocket
message callback for binary.
Sourcepub fn on_close(
self,
value: impl Fn(CloseEvent) + Send + Sync + 'static,
) -> Self
pub fn on_close( self, value: impl Fn(CloseEvent) + Send + Sync + 'static, ) -> Self
WebSocket
close callback.
Sourcepub fn reconnect_limit(self, value: ReconnectLimit) -> Self
pub fn reconnect_limit(self, value: ReconnectLimit) -> Self
Retry times. Defaults to ReconnectLimit::Limited(3)
. Use ReconnectLimit::Infinite
for
infinite retries.
Sourcepub fn reconnect_interval(self, value: u64) -> Self
pub fn reconnect_interval(self, value: u64) -> Self
Retry interval in ms. Defaults to 3000.
Sourcepub fn immediate(self, value: bool) -> Self
pub fn immediate(self, value: bool) -> Self
If true
the WebSocket
connection will immediately be opened when calling this function.
If false
you have to manually call the open
function.
Defaults to true
.
Sourcepub fn protocols(self, value: impl Into<Signal<Option<Vec<String>>>>) -> Self
pub fn protocols(self, value: impl Into<Signal<Option<Vec<String>>>>) -> Self
Sub protocols. See MDN Docs.
Can be set as a signal to support protocols only available after the initial render.
Note that protocols are only updated on the next websocket open() call, not whenever the signal is updated.
Therefore “lazy” protocols should use the immediate(false)
option and manually call open()
.
Source§impl<Rx: ?Sized, E, D, Hb, HbCodec> UseWebSocketOptions<Rx, E, D, Hb, HbCodec>
impl<Rx: ?Sized, E, D, Hb, HbCodec> UseWebSocketOptions<Rx, E, D, Hb, HbCodec>
Sourcepub fn on_message<F>(self, handler: F) -> Self
pub fn on_message<F>(self, handler: F) -> Self
WebSocket
message callback for typed message decoded by codec.
Sourcepub fn heartbeat<NewHb, NewHbCodec>(
self,
interval: u64,
) -> UseWebSocketOptions<Rx, E, D, NewHb, NewHbCodec>
pub fn heartbeat<NewHb, NewHbCodec>( self, interval: u64, ) -> UseWebSocketOptions<Rx, E, D, NewHb, NewHbCodec>
Set the data, codec and interval at which the heartbeat is sent. The heartbeat
is the default value of the NewHb
type.
Trait Implementations§
Auto Trait Implementations§
impl<Rx, E, D, Hb, HbCodec> Freeze for UseWebSocketOptions<Rx, E, D, Hb, HbCodec>where
Rx: ?Sized,
impl<Rx, E, D, Hb, HbCodec> !RefUnwindSafe for UseWebSocketOptions<Rx, E, D, Hb, HbCodec>
impl<Rx, E, D, Hb, HbCodec> Send for UseWebSocketOptions<Rx, E, D, Hb, HbCodec>
impl<Rx, E, D, Hb, HbCodec> Sync for UseWebSocketOptions<Rx, E, D, Hb, HbCodec>
impl<Rx, E, D, Hb, HbCodec> Unpin for UseWebSocketOptions<Rx, E, D, Hb, HbCodec>
impl<Rx, E, D, Hb, HbCodec> !UnwindSafe for UseWebSocketOptions<Rx, E, D, Hb, HbCodec>
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self
into a Left
variant of Either<Self, Self>
if into_left
is true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self
into a Left
variant of Either<Self, Self>
if into_left(&self)
returns true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read more