using Microsoft.AspNetCore.Mvc; using ReboundEmulator.Core.Rooms; using ReboundEmulator.Core; namespace ReboundEmulator.Controllers { public class CDLController : Controller { [HttpGet] [Route("/cdl/cdl-info.jsp")] public IResult CDLInfo(string lkey) { var acct = Sessions.Find(lkey); if (acct is null) return Results.Text("error notloggedin", "text/plain"); // see note below var enti = $"oava {(acct.OwnsPremiumAvatar ? 1 : 0)} obad {(acct.OwnsBadges ? 1 : 0)}"; var body = string.Join(" ", "error", "none", "screenname", Q(acct.ScreenName), "site", Q(acct.Site), "tokens", acct.Tokens.ToString(), "enti", Q(enti), "avatar", Q(acct.Avatar)); return Results.Text(body, "text/plain"); } static string Q(string s) => "'" + s.Replace("\\", "\\\\").Replace("'", "\\'") + "'"; [HttpGet("/cdl/1/login")] public IResult CDLLogin(string name) { var lkey = Sessions.Issue(name); // more satisfying return Results.Text($"\n{lkey}", "text/xml"); } [HttpGet("/cdl/1/cdl-clientprops")] public IActionResult CDLClientProps(string game) { string pathToProps = Path.Combine(AppContext.BaseDirectory, "StaticFiles", "Configs", "CDL", $"{game}.properties"); if (System.IO.File.Exists(pathToProps)) return Ok(System.IO.File.ReadAllText(pathToProps)); else return Ok(); // don't send anything since we don't have the config for it on the server yet } } }