Skip to main content

Net

Struct Net 

Source
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>

Source

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.

Source

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.

Source

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.

Source

pub fn poll_events(&self) -> Vec<NetEvent>

Take every event since the last call. Reads memory only.

Source

pub fn is_open(&self) -> bool

Whether the network is open and attached to the desktop app.

Source

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.

Auto Trait Implementations§

§

impl<'a> Freeze for Net<'a>

§

impl<'a> RefUnwindSafe for Net<'a>

§

impl<'a> Send for Net<'a>

§

impl<'a> Sync for Net<'a>

§

impl<'a> Unpin for Net<'a>

§

impl<'a> UnsafeUnpin for Net<'a>

§

impl<'a> UnwindSafe for Net<'a>

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.