using OMS.NET.DbClass; namespace OMS.NET.Instructs { public class GetPresenceInstruct : Instruct { public GetPresenceInstruct() { this.Type = "get_presence"; } public override Task Handler(string wsid) { return Task.Run(() => { if (GlobalArea.LoginCheckByID(wsid)) { //获取所有在线用户,移除重复 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, }); }); this.ResponseOrBroadcastInstructs.Add(new SendPresenceInstruct() { IsResponse = true, Data = allLoginUsers, }); } }); } } public class SendPresenceInstruct : Instruct { public SendPresenceInstruct() { this.Type = "send_presence"; } } }