arcane-sdk 0.15.0

Arcane Powered game SDK core (ownership tickets, DRM checks)
Documentation
//! Arcane game SDK core.
//!
//! Games build one [`ArcaneClient`] at launch, and pass it nothing: Arcane
//! Powered hands the game process the id of the title in `ARCANE_GAME_ID` and
//! the signed-in account in `ARCANE_USER_ID`. The client verifies ownership
//! once and then holds the result in memory — that `user_id`, that `game_id`,
//! the ownership status and the device fingerprint — so nothing downstream
//! needs the id again.
//!
//! ```no_run
//! use arcane_sdk::ArcaneClient;
//!
//! let client = ArcaneClient::init()?;
//! println!("user={:?} owned={}", client.user_id(), client.is_owned());
//! # Ok::<(), arcane_sdk::SdkError>(())
//! ```
//!
//! Ownership is checked against a locally cached ticket when possible. If the
//! ticket is missing or expired, the SDK asks the Arcane desktop app (loopback
//! `127.0.0.1:39284`) to refresh online, opening the app via deep link when
//! needed.
//!
//! `init` also opens a play session: one background thread reports playtime to
//! the Arcane desktop app once a minute, and — while the player allows it —
//! samples the frame rate in short windows if the game calls
//! [`ArcaneClient::frame`]. It never blocks or fails `init`. See
//! [`SessionSnapshot`].
//!
//! Achievements are opt-in and cost nothing until used: one line unlocks one,
//! and it is idempotent, so a game can call it every time its condition holds.
//!
//! ```no_run
//! # let client = arcane_sdk::ArcaneClient::init()?;
//! client.achievements().unlock("first_blood")?;
//! # Ok::<(), arcane_sdk::SdkError>(())
//! ```
//!
//! Friends are the same shape: one call gives the list with `online` and
//! `in_game` for this title, read straight from the Arcane desktop app.
//!
//! ```no_run
//! # let client = arcane_sdk::ArcaneClient::init()?;
//! client.friends().list()?;
//! # Ok::<(), arcane_sdk::SdkError>(())
//! ```
//!
//! P2P lobbies are another opt-in surface: Arcane hosts the lobby, the join
//! code and the invitations, and carries each member's opaque connection blob.
//! The game keeps its own netcode, or uses the coop network below.
//!
//! ```no_run
//! # use arcane_sdk::Visibility;
//! # let client = arcane_sdk::ArcaneClient::init()?;
//! # let my_endpoint = b"udp://203.0.113.7:7777";
//! let lobby = client.p2p().create_lobby(4, Visibility::FriendsAndCode, my_endpoint)?;
//! for event in client.p2p().poll_events() { /* … */ }
//! # Ok::<(), arcane_sdk::SdkError>(())
//! ```
//!
//! The coop network carries the game's own messages between the members of a
//! lobby, with no port to open: the Arcane desktop app connects the players
//! directly, or through Arcane's relay when it has to.
//!
//! ```no_run
//! # use arcane_sdk::{Channel, NetOptions, Peer};
//! # let client = arcane_sdk::ArcaneClient::init()?;
//! # let lobby_id = "3f2b9c1e-0d4a-4e7b-9a61-5c8e2f7d1b40";
//! client.net().open(lobby_id, NetOptions::default())?;
//! client.net().send(Peer::Host, Channel::Reliable, b"ready")?;
//! # Ok::<(), arcane_sdk::SdkError>(())
//! ```
//!
//! Failures are [`SdkError`], carrying a stable [`code`](SdkError::code), a
//! player-facing [`message`](SdkError::message), a developer-facing
//! [`hint`](SdkError::hint) and a [`context`](SdkError::context) key/value list.

mod achievements;
mod client;
mod desktop;
mod device;
mod error;
mod friends;
mod net;
mod p2p;
mod paths;
mod session;
mod ticket;

pub use achievements::{Achievement, Achievements, Unlock, MAX_ACHIEVEMENT_KEY_LEN};
pub use client::{ArcaneClient, MAX_GAME_ID_LEN};
pub use error::{ErrorCode, OwnershipStatus, SdkError};
pub use friends::{Friend, FriendList, Friends};
pub use net::{
    Channel, Net, NetEvent, NetMessage, NetOptions, Peer, Route, MAX_RELIABLE_MESSAGE, MAX_UNRELIABLE_MESSAGE,
};
pub use p2p::{
    Lobby, LobbyEvent, LobbyMember, LobbyOptions, LobbyPollingState, LobbyQuery, LobbySummary, P2p,
    Visibility, JOIN_CODE_LEN, MAX_LOBBY_METADATA_BYTES, MAX_LOBBY_METADATA_KEY_LEN, MAX_LOBBY_METADATA_PAIRS,
    MAX_LOBBY_METADATA_VALUE_LEN, MAX_LOBBY_PAYLOAD_LEN, MAX_LOBBY_SEARCH_RESULTS,
};
pub use session::{SessionSnapshot, TrackingState};

pub mod ffi;