Esempio n. 1
0
        public MessageIndicationHandlersEx()
        {
            this.messages = new List <MessageIndicationHandlersEx.UnsoMessage>();
            MessageIndicationHandlersEx.UnsoMessage unsoMessage = new MessageIndicationHandlersEx.UnsoMessage("\\+CMTI: \"(\\w+)\",(\\d+)", new MessageIndicationHandlersEx.UnsoHandler(this.HandleDeliverMemoryIndication));
            unsoMessage.StartPattern = "\\+CMTI: ";
            unsoMessage.Description  = "New SMS-DELIVER received (indicated by memory location)";
            this.messages.Add(unsoMessage);
            MessageIndicationHandlersEx.UnsoMessage unsoCompleteChecker = new MessageIndicationHandlersEx.UnsoMessage("\\+CMT: (\\w*),(\\d+)\\r\\n(\\w+)", new MessageIndicationHandlersEx.UnsoHandler(this.HandleDeliverPduModeIndication));
            unsoCompleteChecker.StartPattern    = "\\+CMT: ";
            unsoCompleteChecker.Description     = "New SMS-DELIVER received (indicated by PDU mode version)";
            unsoCompleteChecker.CompleteChecker = new MessageIndicationHandlersEx.UnsoCompleteChecker(this.IsCompleteDeliverPduModeIndication);
            this.messages.Add(unsoCompleteChecker);
            MessageIndicationHandlersEx.UnsoMessage unsoMessage1 = new MessageIndicationHandlersEx.UnsoMessage("\\+CDSI: \"(\\w+)\",(\\d+)", new MessageIndicationHandlersEx.UnsoHandler(this.HandleStatusReportMemoryIndication));
            unsoMessage1.StartPattern = "\\+CDSI: ";
            unsoMessage1.Description  = "New SMS-STATUS-REPORT received (indicated by memory location)";
            this.messages.Add(unsoMessage1);
            MessageIndicationHandlersEx.UnsoMessage unsoCompleteChecker1 = new MessageIndicationHandlersEx.UnsoMessage("\\+CDS: (\\d+)\\r\\n(\\w+)", new MessageIndicationHandlersEx.UnsoHandler(this.HandleStatusReportPduModeIndication));
            unsoCompleteChecker1.StartPattern    = "\\+CDS: ";
            unsoCompleteChecker1.Description     = "New SMS-STATUS-REPORT received (indicated by PDU mode version)";
            unsoCompleteChecker1.CompleteChecker = new MessageIndicationHandlersEx.UnsoCompleteChecker(this.IsCompleteStatusReportPduModeIndication);
            this.messages.Add(unsoCompleteChecker1);

            MessageIndicationHandlersEx.UnsoMessage ussdMessage = new MessageIndicationHandlersEx.UnsoMessage("\\+CUSD:\\s*(\\d+)(?:,\\s*\\\"([^\\\"]*)\\\"(?:,\\s*(\\d+))?)?", new MessageIndicationHandlersEx.UnsoHandler(this.HandleUssdIndication));
            ussdMessage.StartPattern    = "\\+CUSD: ";
            ussdMessage.Description     = "New USSD received";
            ussdMessage.CompleteChecker = new MessageIndicationHandlersEx.UnsoCompleteChecker(this.IsCompleteUssdIndication);
            this.messages.Add(ussdMessage);
        }
Esempio n. 2
0
        /// <summary>
        /// Handles an unsolicited message of the specified input string.
        /// </summary>
        /// <param name="input">The input string to handle, the unsolicited message will be removed</param>
        /// <param name="description">Receives a textual description of the message, may be empty</param>
        /// <returns>The message indication object generated from the message</returns>
        /// <exception cref="T:System.ArgumentException">Input string does not match any of the supported
        /// unsolicited messages</exception>
        public IMessageIndicationObject HandleUnsolicitedMessage(ref string input, out string description)
        {
            IMessageIndicationObject messageIndicationObject;

            List <MessageIndicationHandlersEx.UnsoMessage> .Enumerator enumerator = this.messages.GetEnumerator();
            try
            {
                while (enumerator.MoveNext())
                {
                    MessageIndicationHandlersEx.UnsoMessage current = enumerator.Current;
                    if (!current.IsMatch(input))
                    {
                        continue;
                    }
                    IMessageIndicationObject messageIndicationObject1 = current.Handler(ref input);
                    description             = current.Description;
                    messageIndicationObject = messageIndicationObject1;
                    return(messageIndicationObject);
                }
                throw new ArgumentException("Input string does not match any of the supported unsolicited messages.");
            }
            finally
            {
                enumerator.Dispose();
            }
            return(messageIndicationObject);
        }