Skip to main content

tickets

Proof, signed by Arcadible, that a request comes from your game, and of who's playing. Your game gets a ticket and sends it to your server, which checks it with the Arcadible Server SDK. Checking one needs no key. Each code a call fails with is in Codes, and the limits are in Limits.

import { tickets } from "@arcadible/server-sdk";

interface Tickets {
check(ticket: string, options: CheckOptions): Promise<Ticket>;
}

type CheckOptions = {
server: string;
game: string;
channel: Channel | readonly Channel[];
};

type Channel = "production" | "staging";

type Ticket = {
id: string;
game: string;
build: { site: string; version: string; channel: "production" | "staging" | "local" | string };
player: TicketPlayer | null;
expiresAt: string;
};

type TicketPlayer = { id: string; guest: boolean };

Members​

MemberDescription
check(ticket, options)Checks a ticket your game sent

tickets.check(ticket, options)​

check(ticket: string, options: CheckOptions): Promise<Ticket>

Checks a ticket your game sent, and resolves with what it says. Your game sends one as it connects; your server checks it, then keeps its own session.

const ticket = await tickets.check(bearer, {
server: "https://api.example.com",
game: "8f36cdfb-adad-4f37-b543-63cf1b401455",
channel: "production",
});
OptionValue
serverYour server's own address, as your game lists it in client.server_origins: any URL of it. A ticket for another server fails
gameYour game's id. A ticket for another game fails
channelThe channel your server takes tickets from: "production", "staging", or both as a list. A ticket from another fails. Never "local": arc serve's tickets are taken whatever you name

All three are required. A missing one, or one that isn't what it should be, fails with invalid, as any call's own argument does, with a message that names the option (tickets.check needs …), where a ticket's says Not a ticket for this. There's no default channel, so a production server never takes a staging build's tickets by leaving it out.

FieldValue
idUnique to the ticket. Keep it until expiresAt to refuse a ticket sent twice
gameThe game's id
buildThe build that sent it: its site, the site id in its <site-id>.arcadible.io origin; its version; and its channel, production, staging, or local under arc serve, as a game's own arcadible.build says them. channel is a string: other values may be added
playerThe player, a TicketPlayer, { id, guest }: guest is true for someone logged out, whose id is their device's. null for no one, a guest whose device has no id yet. A ticket carries no name: read one with players.read, which takes this as it is
expiresAtWhen it stops being good, as an ISO time. A ticket lasts 10 minutes
  • Fails with invalid for what isn't a ticket, or isn't one for this server, game, and channel: refuse the request. invalid too for options that aren't the call's, and for an ARCADIBLE_SERVE that doesn't name your own machine, each a mistake to fix, which its message says. expired for one that was good and isn't any more: have your game get another. unavailable when Arcadible's keys couldn't be read and none are held: try again.
  • Reads Arcadible's keys when it has none, again once they've been kept as long as Arcadible says (a minute at least, a day at most, and an hour where it says nothing), and for a key it doesn't know at most once a minute; otherwise it makes no request. Reading them waits up to 10 seconds for Arcadible.
  • Checks the signature and the claims, never the form of an id inside: what Arcadible makes is opaque.
  • Your server's clock may be 30 seconds from Arcadible's, either way.