Struct amethyst_network::NetConnection
source · pub struct NetConnection<E: 'static> {
pub target: SocketAddr,
pub state: ConnectionState,
pub send_buffer: EventChannel<NetEvent<E>>,
pub receive_buffer: EventChannel<NetEvent<E>>,
/* private fields */
}
Expand description
A network connection target data.
Fields
target: SocketAddr
The remote socket address of this connection.
state: ConnectionState
The state of the connection.
send_buffer: EventChannel<NetEvent<E>>
The buffer of events to be sent.
receive_buffer: EventChannel<NetEvent<E>>
The buffer of events that have been received.
Implementations
sourceimpl<E: Send + Sync + 'static> NetConnection<E>
impl<E: Send + Sync + 'static> NetConnection<E>
sourcepub fn new(target: SocketAddr) -> Self
pub fn new(target: SocketAddr) -> Self
Construct a new NetConnection. SocketAddr
is the address that will be connected to.
sourcepub fn send_buffer_early_read(&mut self) -> EventIterator<'_, NetEvent<E>>
pub fn send_buffer_early_read(&mut self) -> EventIterator<'_, NetEvent<E>>
Function used ONLY by NetSocketSystem. Since most users will want to both create the connection and send messages on the same frame, we need a way to read those. Since the NetSocketSystem runs after the creation of the NetConnection, it cannot possibly have registered his reader early enough to catch the initial messages that the user wants to send.
The downside of this is that you are forced to take NetConnection mutably inside of NetSocketSystem. If someone finds a better solution, please open a PR.