using System.Text.Json; namespace OMS.NET.Instructs { public class TextMessageInstruct : Instruct { public TextMessageInstruct() { Type = "broadcast"; Class = "textMessage"; } public override Task Handler(string wsid) { return Task.Run(() => { if (!GlobalArea.LoginCheckByID(wsid)) return;//登录检查不通过则直接退出 if (Data?.GetType() != typeof(JsonElement)) return;//Data 非空和JsonElement类型检查 try { string message = Data.GetProperty("message").GetString(); string conveyor = GlobalArea.GetLoginEmailByID(wsid); string time = GlobalArea.GetCurrentTime(); GlobalArea.Log.Info($"[{time}] {conveyor}:{message}"); ResponseOrBroadcastInstructs.Add(new TextMessageInstruct() { IsBroadcast = true, Conveyor = conveyor, Time = time, Data = Data }); } catch (Exception ex) { GlobalArea.Log.Warn("处理textMessage发生问题:" + ex.Message); } }); } } }