Struct bevy_replicon::server::replicon_server::RepliconServer
source · pub struct RepliconServer { /* private fields */ }
Expand description
Stores information about the server independent from the messaging backend.
The messaging backend is responsible for updating this resource:
- When the server is started or stopped,
Self::set_running
should be used to reflect this. - For receiving messages,
Self::insert_received
should be used. A system to forward messages from the backend to Replicon should run inServerSet::ReceivePackets
. - For sending messages,
Self::drain_sent
should be used to drain all sent messages. A system to forward messages from Replicon to the backend should run inServerSet::SendPackets
.
Implementations§
source§impl RepliconServer
impl RepliconServer
sourcepub fn receive<I: Into<u8>>(
&mut self,
channel_id: I
) -> impl Iterator<Item = (ClientId, Bytes)> + '_
pub fn receive<I: Into<u8>>( &mut self, channel_id: I ) -> impl Iterator<Item = (ClientId, Bytes)> + '_
Receives all available messages from clients over a channel.
All messages will be drained.
sourcepub fn send<I: Into<u8>, B: Into<Bytes>>(
&mut self,
client_id: ClientId,
channel_id: I,
message: B
)
pub fn send<I: Into<u8>, B: Into<Bytes>>( &mut self, client_id: ClientId, channel_id: I, message: B )
Sends a message to a client over a channel.
sourcepub fn set_running(&mut self, running: bool)
pub fn set_running(&mut self, running: bool)
Marks the server as running or stopped.
Should be called only from the messaging backend when the server changes its state.
sourcepub fn is_running(&self) -> bool
pub fn is_running(&self) -> bool
Returns true
if the server is running.
Trait Implementations§
source§impl Default for RepliconServer
impl Default for RepliconServer
source§fn default() -> RepliconServer
fn default() -> RepliconServer
Returns the “default value” for a type. Read more
impl Resource for RepliconServer
Auto Trait Implementations§
impl Freeze for RepliconServer
impl RefUnwindSafe for RepliconServer
impl Send for RepliconServer
impl Sync for RepliconServer
impl Unpin for RepliconServer
impl UnwindSafe for RepliconServer
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
Mutably borrows from an owned value. Read more
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>
Convert
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>
Convert
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)
Convert
&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)
Convert
&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
Creates
Self
using data from the given World
.