Esempio n. 1
0
        /// <summary> Constructor </summary>
        /// <param name="defaultEncoding"></param>
        /// <param name="header"></param>
        public SmppBuffer(DataCodings defaultEncoding, Header header)
        {
            DefaultEncoding = defaultEncoding;

            ListBuffer = new List<byte>();

            AddUInt((uint) header.Command);
            AddUInt((uint) header.Status);
            AddUInt((uint) header.Sequence);

            // Use AddFinalLength to add the length to the
            // beginning of the buffer
        }
Esempio n. 2
0
        /// <summary> Constructor </summary>
        /// <param name="defaultEncoding"></param>
        /// <param name="header"></param>
        public Header(DataCodings defaultEncoding, Header header)
        {
            DefaultEncoding = defaultEncoding;

            PduData = null;

            Length = header.Length;
            Command = header.Command;
            Status = header.Status;
            Sequence = header.Sequence;
        }
Esempio n. 3
0
        /// <summary> Extracts the header portion of the PDU </summary>
        /// <param name="header"></param>
        /// <param name="offset"></param>
        public void ExtractHeader(Header header, ref int offset)
        {
            int startingOffset = offset;

            // Extract the header
            header.Length = ExtractInt(ref offset);
            header.Command = (CommandSet) ExtractInt(ref offset);
            header.Status = (CommandStatus) ExtractInt(ref offset);
            header.Sequence = ExtractInt(ref offset);

            // Extract the entire pdu
            header.PduData = new SmppBuffer(header.DefaultEncoding, ListBuffer.GetRange(startingOffset, (int) header.Length));
        }
Esempio n. 4
0
        /// <summary> Creates a new Header object from the buffer </summary>
        /// <param name="offset"></param>
        /// <returns> Header </returns>
        public Header PeekHeader(int offset)
        {
            Header header = new Header(DefaultEncoding);

            try
            {
                header.Length = ExtractInt(ref offset);
                header.Command = (CommandSet) ExtractInt(ref offset);
                header.Status = (CommandStatus) ExtractInt(ref offset);
                header.Sequence = ExtractInt(ref offset);
            }

            catch
            {
                header = null;
            }

            return header;
        }
Esempio n. 5
0
 /// <summary> Called to add a header to the buffer </summary>
 /// <param name="header"></param>
 public void AddHeader(Header header)
 {
     AddUInt((uint) header.Command);
     AddUInt((uint) header.Status);
     AddUInt((uint) header.Sequence);
 }
Esempio n. 6
0
        private static Guid? PduDetailsHandler(string logKey, PduDirectionTypes pduDirectionType, Header pdu, List<PduPropertyDetail> details)
        {
            Guid? pduHeaderId = null;

            try
            {
                // Do not store these
                if ((pdu.Command == CommandSet.EnquireLink) || (pdu.Command == CommandSet.EnquireLinkResp))
                {
                    return null;
                }

                string connectionString = null; // If null InsertPdu will just log to stdout
                int serviceId = 0;              // Internal Id used to track multiple SMSC systems

                PduApp.InsertPdu(logKey, connectionString, serviceId, pduDirectionType, details, pdu.PduData.BreakIntoDataBlocks(4096), out pduHeaderId);
            }

            catch (Exception exception)
            {
                Console.WriteLine("{0}", exception.Message);
            }

            return pduHeaderId;
        }
Esempio n. 7
0
        /// <summary> Called when a pdu details are available </summary>
        /// <param name="send"></param>
        /// <param name="pduDirectionType"></param>
        /// <param name="pdu"></param>
        /// <param name="details"></param>
        /// <returns> External Id </returns>
        private Guid? ClientEventPduDetails(object send, PduDirectionTypes pduDirectionType, Header pdu, List<PduPropertyDetail> details)
        {
            Guid? externalId = null;

            if (PduDetailsEventHandler != null)
            {
                externalId = PduDetailsEventHandler(LogKey, pduDirectionType, pdu, details);
            }

            return externalId;
        }
Esempio n. 8
0
        /// <summary> Called when a pdu details are available </summary>
        /// <param name="logKey"></param>
        /// <param name="pduDirectionType"></param>
        /// <param name="pdu"></param>
        /// <param name="details"></param>
        /// <returns> External Id </returns>
        private Guid? PduDetailsConnectionHandler(string logKey, PduDirectionTypes pduDirectionType, Header pdu, List<PduPropertyDetail> details)
        {
            Guid? externalId = null;

            if (PduDetailsEventHandler != null)
            {
                externalId = PduDetailsEventHandler(logKey, pduDirectionType, pdu, details);
            }

            return externalId;
        }
Esempio n. 9
0
 /// <summary> Resets the object for new use </summary>
 public void Release()
 {
     SignalEvent.Reset();
     ResponseObject = null;
 }
Esempio n. 10
0
        /// <summary> Called to fire the pdu detail event </summary>
        /// <param name="pduDirectionType"></param>
        /// <param name="pdu"></param>
        internal void OnPduDetails(PduDirectionTypes pduDirectionType, Header pdu)
        {
            try
            {
                if (PduDetailsEvent != null)
                {
                    if (pduDirectionType == PduDirectionTypes.Sent)
                    {
                        // Build the PDU
                        pdu.PduData = new SmppBuffer(DefaultEncoding, ((IPacket) pdu).GetPDU());
                    }

                    pdu.ExternalId = PduDetailsEvent(this, pduDirectionType, pdu, ((IPduDetails) pdu).Details());
                }
            }

            catch
            {
            }
        }