public static void Deal(string message) { bool success = JsonUtil.ParseStruct <SettingStruct>(message, out SettingStruct ss); if (success) { switch (ss.type) { case SettingType.Form: DealWithForm(ss.content); break; case SettingType.Message: DealWithMessage(ss.content); break; case SettingType.Log: DealWithLog(ss.content); break; default: LogClerk.Error("Invalid setting type"); break; } } }
public static void Deal(string message) { bool success = JsonUtil.ParseStruct(message, out MessageStruct ms); if (success) { switch (ms.type) { case MessageType.setting: SettingsManager.Deal(ms.content); break; case MessageType.action: ActionManager.Deal(ms.content); break; case MessageType.nursery: NurseryManager.Deal(ms.content); break; //case MessageType.log: break; default: LogClerk.Error("Invalid message type"); break; } } }
private static void Send(object sdu, SettingCode sc) { SettingStruct?pdu = null; switch (sdu) { case FormSettingStruct fss: pdu = PDU(SettingType.Form, sc, JsonConvert.SerializeObject(fss)); break; case MessageSettingStruct mss: pdu = PDU(SettingType.Message, sc, JsonConvert.SerializeObject(mss)); break; case LogSettingStruct lss: pdu = PDU(SettingType.Log, sc, JsonConvert.SerializeObject(lss)); break; default: LogClerk.Error("Invalid setting message type.", 2); break; } if (pdu != null) { MessageManager.Send(pdu); } }
public static void Send(object sdu) { MessageStruct?pdu = null; switch (sdu) { case ActionStruct ass: pdu = PDU(MessageType.action, JsonConvert.SerializeObject(ass)); break; case LoggingStruct ls: pdu = PDU(MessageType.logging, JsonConvert.SerializeObject(ls)); break; case NurseryStruct ns: pdu = PDU(MessageType.nursery, JsonConvert.SerializeObject(ns)); break; case SettingStruct ss: pdu = PDU(MessageType.setting, JsonConvert.SerializeObject(ss)); break; default: LogClerk.Error("Invalid message SDU type"); break; } if (pdu != null) { PipeMessenger.Post(JsonConvert.SerializeObject(pdu)); } }