[−][src]Struct amethyst_network::NetConnection
A remote connection to some endpoint.
This type is a Component
, and it is used by systems too:
- Queue received data into this type
- Read the queued data from the user for transmission.
Remark
Note that this type does not perform any reading or writing, this is done only within systems. This type acts as a container for to send and received data.
Fields
target_addr: SocketAddr
The target remote socket address who is listening for incoming packets.
state: ConnectionState
The state of the connection.
Methods
impl<E: Send + Sync + 'static> NetConnection<E>
[src]
pub fn new(target_addr: SocketAddr) -> Self
[src]
Construct a new NetConnection
.
SocketAddr
: the remote endpoint, from here the data will be send to and received from.
pub fn queue_iter<I>(&mut self, iter: I) where
I: IntoIterator<Item = NetEvent<E>>,
I::IntoIter: ExactSizeIterator,
[src]
I: IntoIterator<Item = NetEvent<E>>,
I::IntoIter: ExactSizeIterator,
Queues the given event iterator of events for transmission.
This function writes the passed event iterator to a buffer which can be read by a System
.
It is the job of the System
to send those events to the remote client.
pub fn queue_vec(&mut self, events: &mut Vec<NetEvent<E>>)
[src]
Queues the given vector of events for transmission.
This function writes the passed event vector to a buffer which can be read by a System
.
It is the job of the System
to send those events to the remote client.
pub fn queue(&mut self, event: NetEvent<E>)
[src]
Queues a single event for transmission.
This function writes the passed event to a buffer which can be read by a System
.
It is the job of the System
to send this event to the remote client.
pub fn received_events(
&self,
reader_id: &mut ReaderId<NetEvent<E>>
) -> EventIterator<NetEvent<E>>
[src]
&self,
reader_id: &mut ReaderId<NetEvent<E>>
) -> EventIterator<NetEvent<E>>
Returns an iterator over the received events.
reader_id
: the reader id of the registered reader.
Remark
- To be able to read events, a reader id is required. This is required for the underlying ringbuffer.
The reader id stores information of where in the ringbuffer the reader has read from earlier.
Please checkout
register_reader
which will return aReaderId
that allows you to read the received events.
pub fn register_reader(&mut self) -> ReaderId<NetEvent<E>>
[src]
Returns a ReaderId
that can be used to read from the received events.
Remark
- To be able to read events, a reader id is required. This is because otherwise the channel wouldn't know where in the ringbuffer the reader has read to earlier. This information is stored in the reader id.
Trait Implementations
impl<E: PartialEq> Eq for NetConnection<E>
[src]
impl<E> PartialEq<NetConnection<E>> for NetConnection<E>
[src]
fn eq(&self, other: &Self) -> bool
[src]
#[must_use]
fn ne(&self, other: &Rhs) -> bool
1.0.0[src]
This method tests for !=
.
impl<E: 'static> Serialize for NetConnection<E>
[src]
fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error> where
__S: Serializer,
[src]
__S: Serializer,
impl<E: Send + Sync + 'static> Component for NetConnection<E>
[src]
type Storage = VecStorage<Self>
Associated storage type for this component.
Auto Trait Implementations
impl<E> Unpin for NetConnection<E> where
E: Unpin,
E: Unpin,
impl<E> Sync for NetConnection<E> where
E: Sync,
E: Sync,
impl<E> Send for NetConnection<E> where
E: Send + Sync,
E: Send + Sync,
impl<E> !UnwindSafe for NetConnection<E>
impl<E> !RefUnwindSafe for NetConnection<E>
Blanket Implementations
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,
type Error = <U as TryFrom<T>>::Error
The type returned in the event of a conversion error.
fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>
[src]
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Same<T> for T
[src]
type Output = T
Should always be Self
impl<SS, SP> SupersetOf<SS> for SP where
SS: SubsetOf<SP>,
[src]
SS: SubsetOf<SP>,
fn to_subset(&self) -> Option<SS>
[src]
fn is_in_subset(&self) -> bool
[src]
unsafe fn to_subset_unchecked(&self) -> SS
[src]
fn from_subset(element: &SS) -> SP
[src]
impl<T> Resource for T where
T: Any + Send + Sync,
[src]
T: Any + Send + Sync,
impl<T> Any for T where
T: Any,
[src]
T: Any,
fn get_type_id(&self) -> TypeId
[src]
impl<T> Event for T where
T: Send + Sync + 'static,
[src]
T: Send + Sync + 'static,