~skye/poker/jax/room.php

view raw


<?php

require '../com.php';
require '../src/db.php';

function room_to_array($r): array {
	return [
		"name" => $r->name,
		"size" => $r->size,
		"hash" => $r->hash,
		"oid" => $r->oid
	];
}

$data = array();

$db = new Database('../run/poker.db');
$me = whoami($db);

if (!!$me) {
	$data["logged-in"] = true;
} else {
	$data["error"] = "You are not logged in!";
}

/* TODO: $r = Room::from_hash($h); */
$data["room"] = room_to_array($r);

echo json_encode($data);

?>