using Microsoft.AspNetCore.Mvc; using Campus_live_rewrite.api.dbs; namespace Campus_live_rewrite.Controllers { // --------------------------------------------------------------------------------- // Room lookup for the Tachyon voice server. // // Tachyon has NO room id on its wire - the client's voice ConnectionData carries only // the AccountId (plaintext) plus opaque RSA blobs. So Tachyon resolves which room a // speaker is in by asking us: GET /tachyon?id=, expecting a BARE numeric // roomInstanceId in text/plain (see tachyon-server-master/src/room_lookup.cpp - it // strtoull's the body and treats 0 / non-200 / non-numeric as "isolate this client", // i.e. they hear no one). It scopes its Dissonance relay per returned room id. // // Set Tachyon's config room_url = https:///tachyon (it appends ?id=). // // Unauthenticated on purpose: room_lookup.cpp issues a plain GET with no token, exactly // as the RecFlare reference does. The only thing exposed is which room-instance a given // account is in, keyed on a numeric id we already hand out publicly; the id is validated // as an integer before use. Returns "0" (nowhere) for anything we can't positively place, // which fails safe: Tachyon isolates the client rather than leaking cross-room voice. // --------------------------------------------------------------------------------- [ApiController] public class TachyonController : ControllerBase { [HttpGet("/tachyon")] public IActionResult ResolveRoom([FromQuery] string? id) { if (string.IsNullOrWhiteSpace(id) || !ulong.TryParse(id, out var accountId)) return Content("0", "text/plain"); var (online, room) = HeartbeatDB.PeekPresence(accountId); long instance = (online && room != null) ? room.roomInstanceId : 0; return Content(instance.ToString(), "text/plain"); } } }