using System; using Server.Accounting; using Server.Custom.Bridge; using Server.Mobiles; namespace Server.Custom { /// /// Triggers the [link flow for a seeded character without a game client, so the account /// linking round-trip can be tested end to end: RequestLink emits link.request, the test /// sidecar reads the code and sends link.confirm, and the account gets tagged. /// /// Test scaffolding. Never deployed. Writes an account tag (persisted on save). /// public static class BridgeLinkProbe { public static void Initialize() { if (Config.Get("Bridge.LinkProbeOnStart", false)) EventSink.ServerStarted += () => Timer.DelayCall(TimeSpan.FromSeconds(3.0), Run); } private static void Run() { try { // Use a seed account not already linked. seed_001 slot 0. var acct = Accounting.Accounts.GetAccount("seed_001") as Account; var pm = acct == null ? null : acct[0] as PlayerMobile; if (pm == null) { Console.WriteLine("[LinkProbe] seed_001 slot 0 not found; seed the world first"); return; } var existing = acct.GetTag("WebsiteUserId"); if (existing != null) Console.WriteLine("[LinkProbe] seed_001 already linked to {0}; re-running anyway", existing); Console.WriteLine("[LinkProbe] requesting link for seed_001 / {0}", pm.Name); BridgeAccountLink.RequestLink(pm); Console.WriteLine("[LinkProbe] link.request emitted; watch for the code -> link.confirm -> link.ok"); // Give the confirm time to land and set the tag, then save so it reaches // accounts.xml. This proves persistence across a restart. Timer.DelayCall(TimeSpan.FromSeconds(5.0), () => { var tag = acct.GetTag("WebsiteUserId"); Console.WriteLine("[LinkProbe] after confirm, seed_001 WebsiteUserId tag = {0}", tag ?? "(null)"); Console.WriteLine("[LinkProbe] saving world to persist the tag..."); World.Save(); Console.WriteLine("[LinkProbe] saved"); }); } catch (Exception ex) { Console.WriteLine("[LinkProbe] FAILED: " + ex); } } } }