Esempio n. 1
0
        private void PduReceivedEventHander(object sender, PduReceivedEventArgs e)
        {
            MessageBox.Show("Сработало событие received");
            SingleDestinationPDU pdu = e.Request as SingleDestinationPDU;

            if (pdu == null)
            {
                return;
            }

            Udh    udh     = null;                    //We need to test if the UDH field is present
            string message = null;                    //This will hold the message text

            pdu.GetMessageText(out message, out udh); //Get message text and UDH from the PDU
            MessageBox.Show("Пришедшее на номер: " + message + " , " + pdu.Header.ErrorCode.ToString());
        }
Esempio n. 2
0
        /// <summary>
        /// Creates a <see cref="TextMessage"/> from a received <see cref="SingleDestinationPDU"/>
        /// </summary>
        /// <param name="pdu">The PDU from which a <see cref="TextMessage"/> is constructed</param>
        /// <returns>A <see cref="TextMessage"/> represening a text message extracted from the received PDU</returns>
        public static TextMessage CreateMessage(SingleDestinationPDU pdu)
        {
            //This version supports only text messages
            Udh    udh     = null;
            string message = null;

            pdu.GetMessageText(out message, out udh);
            TextMessage sms = null;

            //Check if the udh field is present
            if (udh != null)
            {
                sms = new TextMessage(udh.SegmentID, udh.MessageCount, udh.MessageSequence);
            }
            else
            {
                sms = new TextMessage();
            }
            sms.Text               = message == null ? "" : message;
            sms.SourceAddress      = pdu.SourceAddress.Address;
            sms.DestinationAddress = pdu.DestinationAddress.Address;
            return(sms);
        }