using OMS.NET.DbClass; namespace OMS.NET.Instructs { public class GetPresenceInstruct : Instruct { public GetPresenceInstruct() { Type = "get_presence"; } public override Task Handler(string wsid) { return Task.Run(() => { if (!GlobalArea.LoginCheckByID(wsid)) return;//登录检查,不通过则直接退出 //获取所有在线用户,移除重复 List emails = GlobalArea.UserConnects.Where(u => u.UserEmail != null) .Select(u => u.UserEmail).Distinct().ToList(); List allLoginUsers = new(); emails.ForEach(email => { AccountData accountData = GlobalArea.GetLoginAccountData(email)!; //由于是已登录用户,默认都能查询到值 allLoginUsers.Add(new { userEmail = accountData.UserEmail, userQq = accountData.UserQQ, userName = accountData.UserName, headColor = accountData.HeadColor, }); }); ResponseOrBroadcastInstructs.Add(new Instruct() { IsResponse = true, Type = "send_presence", Data = allLoginUsers, }); }); } } }