示例#1
0
        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;
                }
            }
        }
示例#2
0
        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;
                }
            }
        }
示例#3
0
        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);
            }
        }
示例#4
0
        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));
            }
        }