public static async Task GetIncursions(Command cmd) { var who = cmd.XmppMessage.From; Incursions incursionClass = Incursions.Get(); await incursionClass.CheckIncursions(); incursionClass.Set(); if (cmd.XmppMessage.Type == MessageType.GroupChat) { // Lets get their jid Jid directJid = JabberClient.Instance.GetJidForResource(who?.Resource); if (directJid == null) { Console.WriteLine("[Error] Can't reverse Resource to Jid. Resource: \"{0}\"", who?.Resource); return; } await JabberClient.Instance.SendMessage(directJid, incursionClass.ToString()); } else { await JabberClient.Instance.SendMessage(who.Bare, incursionClass.ToString()); } }
public static Incursions Get() { var m_incursions = Jabber.RedisHelper.Get <Incursions>(WaitlistRedisKey); if (m_incursions == null) { m_incursions = new Incursions(); } return(m_incursions); }
static void Main(string[] args) { // ManualResetEvent threadBlocker = new ManualResetEvent(false); // // Wait for control+c // Console.CancelKeyPress += delegate (object sender, ConsoleCancelEventArgs e) // { // threadBlocker.Set(); // }; JabberClient.Instance.OnJabberConnected += async delegate() { //await JabberClient.Instance.JoinRoom("*****@*****.**"); await JabberClient.Instance.JoinRoom("*****@*****.**"); await JabberClient.Instance.JoinRoom("*****@*****.**"); await JabberClient.Instance.JoinRoom("*****@*****.**"); }; Commands.Register(); // TODO: I'm not sure if this is the best way to create one off things. Seems to be in a console app. Task jabberTask = new Task(async() => { await JabberClient.Instance.Run(); }, TaskCreationOptions.LongRunning); Task commandTask = new Task(async() => { await CommandDispatcher.Instance.ProcessQueue(); }, TaskCreationOptions.LongRunning); jabberTask.Start(); commandTask.Start(); DateTime now = DateTime.Now; Scheduler.IntervalInMinutes(now.Hour, now.Minute + 1, 5, async() => { Incursions inc = Incursions.Get(); await inc.UpdateIncursions(); inc.Set(); }); CreateWebHostBuilder(args).Build().Run(); // Block JabberClient.Instance.Disconnect().GetAwaiter().GetResult(); }