pub struct Net<'a> { /* private fields */ }Expand description
The coop network of this game. Get it from
ArcaneClient::net.
Implementations§
Source§impl<'a> Net<'a>
impl<'a> Net<'a>
Sourcepub fn open(&self, lobby_id: &str, options: NetOptions) -> Result<(), SdkError>
pub fn open(&self, lobby_id: &str, options: NetOptions) -> Result<(), SdkError>
Open the network on a lobby this player already created or joined.
One synchronous loopback round trip, then two local connections. It
returns once the game is attached to the desktop app; links to the
other members come up afterwards and are announced by
NetEvent::PeerConnected. Opening again replaces the previous
network.
§Errors
invalid_argument for a malformed lobby id (raised before any call),
not_in_lobby, no_open_session, lobby_not_found, lobby_closed,
network_required (offline, or under ARCANE_OFFLINE_ONLY),
arcane_unavailable, feature_unavailable when the desktop app
predates the coop network.
Sourcepub fn send(
&self,
peer: Peer,
channel: Channel,
data: &[u8],
) -> Result<(), SdkError>
pub fn send( &self, peer: Peer, channel: Channel, data: &[u8], ) -> Result<(), SdkError>
Send one message.
Writes to a loopback socket and returns; it never waits on the other player. A message to a peer that is not connected is dropped by the desktop app without an error.
§Errors
invalid_argument when data is longer than the channel allows
(MAX_RELIABLE_MESSAGE or MAX_UNRELIABLE_MESSAGE),
lobby_closed when the network is not open,
arcane_unavailable when the local socket fails.
Sourcepub fn receive(&self) -> Option<NetMessage>
pub fn receive(&self) -> Option<NetMessage>
Take the next received message, or None when there is none.
Reads memory only. Drain it every frame: past 64 MiB waiting, new
unreliable messages are dropped and a reliable one closes the network
with the reason receive_overflow.
Sourcepub fn poll_events(&self) -> Vec<NetEvent>
pub fn poll_events(&self) -> Vec<NetEvent>
Take every event since the last call. Reads memory only.
Sourcepub fn close(&self)
pub fn close(&self)
Close the network: every link drops, for this player only.
Does nothing when the network was never opened. Otherwise one loopback round trip of at most 2 seconds, best effort: the local sockets are closed whatever the desktop app answers. Messages not yet received are discarded.