Search by

tilttek / table-presence

phil

Who is at an online table, away or on a break, counted once per person across tabs, and the table's own status, such as paused.

Package info

github.com/TiltTek/table-presence

Homepage

pkg:composer/tilttek/table-presence

Statistics

Installs: 1

Dependents: 0

Suggesters: 0

Stars: 0

Open Issues: 0

0.1.0-alpha 2026-11-29 22:00 UTC

This package is auto-updated.

Last update: 2026-11-30 02:53:49 UTC


README

Who is at an online table, away or on a break, and the table's own status.

tilttek/table-presence tells the members of an online game table who is there with them. A member counts once however many tabs or devices they open, a reload or a short drop is not a departure, and the table hears that someone arrived or left once per stay, never at each heartbeat.

  • Connections, counted once. Each tab sends a heartbeat; a member is at the table while one of their connections is live, and through a grace delay after the last one closes or goes silent — 45 seconds of timeout and 20 of grace, by default.
  • What a member says. Here, away from the screen, or on a break with the minutes until they expect to be back. The member chooses it; silence never makes anyone "away".
  • Who sees whom. Each member shows their presence to the whole table, to the game master and assistants only, or to nobody; a member hidden from a viewer, or who blocked them, is offline to that viewer, never "hidden". No moment of a last connection is ever shown.
  • The table's status. Gathering, playing, paused or on a break, with a short label such as "Scene 3".
  • Erasable. A member's presence is erased on request; a member who leaves is here again at their next stay.

The service reads the time from a PSR-20 clock and from nothing else. The facts of a table — opened, a member admitted, arrived, left, removed, their availability or visibility changed, their presence erased, the status changed, closed — go to an observer, each once, by identifiers only.

It is a plain PHP library: one service, value objects, ports and a store kept in memory for tests.

Status

Part State
Table, Member, Connection, PresencePolicy: a table and its members' presence, bounded and checked Implemented and tested
Presence: open, admit, remove, connect, disconnect, sweep, availability, visibility, status, forget, close Implemented and tested
View\PresenceView and View\MemberPresence: the presence as each viewer may see it Implemented and tested
Store\InMemoryPresenceStore: the store of the tests Implemented and tested
A Symfony bundle: the Doctrine store, Mercure, the scheduled sweep and a Stimulus heartbeat Not started

Documentation

Document What it covers
Installation Requirements, installing and wiring.
Presence Members, connections, the grace delay, the sweep, availability, visibility, the table's status, erasing and closing.
Extension points The store, the observer and its events, the block list, the clock, and who may do what.
Exceptions PresenceException and its exceptions.
Testing The library's tests and its benchmarks.
Reference Every type of the library, with its role.

Quick start

use Tilttek\TablePresence\Availability;
use Tilttek\TablePresence\Presence;
use Tilttek\TablePresence\Role;
use Tilttek\TablePresence\TableStatus;

$presence = new Presence($store, $clock, $observer);       // your PresenceStore, a PSR-20 clock, an observer

$presence->open('table-4', ['gm-1' => Role::GameMaster, 'player-1' => Role::Player, 'player-2' => Role::Player]);
$presence->connect('table-4', 'player-1', 'tab-a');        // player 1 arrives; each heartbeat calls it again
$presence->setAvailability('table-4', 'player-1', Availability::OnBreak, 10);
$presence->setStatus('table-4', TableStatus::Playing, 'Scene 3');
$presence->disconnect('table-4', 'player-1', 'tab-a');     // still there through the grace delay
$presence->sweep('table-4');                               // every few seconds: who left

$presence->view('table-4', 'player-2')->toArray();         // what player 2 may see

Requirements

PHP 8.5 or later, with psr/clock.

Contributing

Contributions are welcome on the PHIL monorepo: read the contribution guide and the code of conduct. Report a vulnerability privately, as the security policy explains, never in a public issue.

License

MIT, © Philippe Gamache, doing business as Le Gnome Archiviste; a Tilttek project. See LICENSE.