Struct bevy_replicon::client::replicon_client::RepliconClient
source · pub struct RepliconClient { /* private fields */ }
Expand description
Stores information about a client independent from the messaging backend.
The messaging backend is responsible for updating this resource:
- When the messaging client changes its status (connected, connecting and disconnected),
Self::set_status
should be used to reflect this. - For receiving messages,
Self::insert_received
should be to used. A system to forward backend messages to Replicon should run inClientSet::ReceivePackets
. - For sending messages,
Self::drain_sent
should be used to drain all sent messages. A system to forward Replicon messages to the backend should run inClientSet::SendPackets
.
Implementations§
source§impl RepliconClient
impl RepliconClient
sourcepub fn receive<I: Into<u8>>(
&mut self,
channel_id: I,
) -> impl Iterator<Item = Bytes> + '_
pub fn receive<I: Into<u8>>( &mut self, channel_id: I, ) -> impl Iterator<Item = Bytes> + '_
Receives all available messages from the server over a channel.
All messages will be drained.
sourcepub fn send<I: Into<u8>, B: Into<Bytes>>(&mut self, channel_id: I, message: B)
pub fn send<I: Into<u8>, B: Into<Bytes>>(&mut self, channel_id: I, message: B)
Sends a message to the server over a channel.
sourcepub fn set_status(&mut self, status: RepliconClientStatus)
pub fn set_status(&mut self, status: RepliconClientStatus)
Sets the client connection status.
Should be called only from the messaging backend when the client status changes.
Discards all messages if the state changes from RepliconClientStatus::Connected
.
See also Self::status
.
sourcepub fn status(&self) -> RepliconClientStatus
pub fn status(&self) -> RepliconClientStatus
Returns the current client status.
See also Self::set_status
.
sourcepub fn is_disconnected(&self) -> bool
pub fn is_disconnected(&self) -> bool
Returns true
if the client is disconnected.
See also Self::status
.
sourcepub fn is_connecting(&self) -> bool
pub fn is_connecting(&self) -> bool
Returns true
if the client is connecting.
See also Self::status
.
sourcepub fn is_connected(&self) -> bool
pub fn is_connected(&self) -> bool
Returns true
if the client is connected.
See also Self::status
.
sourcepub fn id(&self) -> Option<ClientId>
pub fn id(&self) -> Option<ClientId>
Returns the client’s ID.
The client ID is available only if the client state is RepliconClientStatus::Connected
.
See also Self::status
.
sourcepub fn drain_sent(&mut self) -> impl Iterator<Item = (u8, Bytes)> + '_
pub fn drain_sent(&mut self) -> impl Iterator<Item = (u8, Bytes)> + '_
Removes all sent messages, returning them as an iterator with channel.
Should be called only from the messaging backend.
Trait Implementations§
source§impl Default for RepliconClient
impl Default for RepliconClient
source§fn default() -> RepliconClient
fn default() -> RepliconClient
impl Resource for RepliconClient
Auto Trait Implementations§
impl Freeze for RepliconClient
impl RefUnwindSafe for RepliconClient
impl Send for RepliconClient
impl Sync for RepliconClient
impl Unpin for RepliconClient
impl UnwindSafe for RepliconClient
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> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
source§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Box<dyn Trait>
(where Trait: Downcast
) to Box<dyn Any>
. Box<dyn Any>
can
then be further downcast
into Box<ConcreteType>
where ConcreteType
implements Trait
.source§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Rc<Trait>
(where Trait: Downcast
) to Rc<Any>
. Rc<Any>
can then be
further downcast
into Rc<ConcreteType>
where ConcreteType
implements Trait
.source§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
&Trait
(where Trait: Downcast
) to &Any
. This is needed since Rust cannot
generate &Any
’s vtable from &Trait
’s.source§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&mut Trait
(where Trait: Downcast
) to &Any
. This is needed since Rust cannot
generate &mut Any
’s vtable from &mut Trait
’s.source§impl<T> DowncastSync for T
impl<T> DowncastSync for T
source§impl<T> FromWorld for Twhere
T: Default,
impl<T> FromWorld for Twhere
T: Default,
source§fn from_world(_world: &mut World) -> T
fn from_world(_world: &mut World) -> T
Self
using data from the given World
.