Exemplo n.º 1
0
        /// <summary>
        /// This method gets the buffer and returns an instance of class
        /// corresponding to the type of the PDU which was in the buffer; the
        /// fields of the returned PDU are set to the data from the buffer.
        /// </summary>
        public static SmppPdu Create(Stream buffer)
        {
            // Read the length and id from the buffer
            SmppReader reader = new SmppReader(buffer);
            int        length = reader.ReadInt32();
            int        id     = reader.ReadInt32();

            // If we don't have the entire message yet, then throw an exception.
            if (buffer.Length < length)
            {
                throw new IncompletePduException();
            }

            // Create a new PDU
            SmppPdu pdu = PduFactory.CreatePdu(id);

            if (pdu != null)
            {
                // Reset back to the length
                buffer.Seek(-8, SeekOrigin.Current);

                // Stream the whole thing in
                pdu.Deserialize(reader);
                return(pdu);
            }

            // Not found in our list of supported PDUs
            throw new UnknownPduException(id);
        }
Exemplo n.º 2
0
 /// <summary>
 /// Compares two PDU. Two PDUs are equal if their sequence number is equal.
 /// </summary>
 public override bool Equals(object obj)
 {
     if (obj != null && (obj is SmppPdu))
     {
         SmppPdu pdu = (SmppPdu)obj;
         return(CommandId == pdu.CommandId && sequenceNumber_ == pdu.SequenceNumber);
     }
     return(false);
 }
Exemplo n.º 3
0
 /// <summary>
 /// This is the entrypoint which is called by the session object to dispatch
 /// a given PDU to the handler.
 /// </summary>
 /// <param name="state"></param>
 /// <param name="pdu"></param>
 /// <returns></returns>
 public static bool Dispatch(SmppSessionState state, SmppPdu pdu)
 {
     // Quick validation of the received PDU; make sure the command id matches up
     // to the type of PDU received and that we have a handler.
     if (typeMap_.ContainsKey(pdu.CommandId))
     {
         PduHandler handler = typeMap_[pdu.CommandId];
         try {
             handler.InternalDispatch(state, pdu);
             return(true);
         } catch (InvalidCastException) {
         }
     }
     return(false);
 }
Exemplo n.º 4
0
        /// <summary>
        /// This method walks the Pdu list and creates new Pdu object instances
        /// using the existing one already created.
        /// </summary>
        /// <param name="commandId">Command Id to create</param>
        /// <returns>New Pdu object</returns>
        public static SmppPdu CreatePdu(int commandId)
        {
            int size = pduFactory_.Count;

            for (int i = 0; i < size; i++)
            {
                SmppPdu pdu = (SmppPdu)pduFactory_[i];
                if (pdu != null && pdu.CommandId == commandId)
                {
                    try {
                        return((SmppPdu)Activator.CreateInstance(pdu.GetType()));
                    } catch (Exception) {
                    }
                }
            }
            return(null);
        }
Exemplo n.º 5
0
 /// <summary>
 /// This method must be overridden in implementations to cast the PDU
 /// to a concrete type and call the appropriate session state method.
 /// </summary>
 /// <param name="state">Session state</param>
 /// <param name="pdu">PDU</param>
 /// <returns></returns>
 public virtual void InternalDispatch(SmppSessionState state, SmppPdu pdu)
 {
     throw new NotImplementedException();
 }
Exemplo n.º 6
0
 public override void InternalDispatch(SmppSessionState state, SmppPdu pdu)
 {
     state.Process((list_dls)pdu);
 }
Exemplo n.º 7
0
 public override void InternalDispatch(SmppSessionState state, SmppPdu pdu)
 {
     state.Process((enquire_sub)pdu);
 }
Exemplo n.º 8
0
 public override void InternalDispatch(SmppSessionState state, SmppPdu pdu)
 {
     state.Process((cancel_broadcast_sm)pdu);
 }
Exemplo n.º 9
0
 public override void InternalDispatch(SmppSessionState state, SmppPdu pdu)
 {
     state.Process((submit_multi)pdu);
 }
Exemplo n.º 10
0
 public override void InternalDispatch(SmppSessionState state, SmppPdu pdu)
 {
     state.Process((bind_transceiver_resp)pdu);
 }
Exemplo n.º 11
0
 public override void InternalDispatch(SmppSessionState state, SmppPdu pdu)
 {
     state.Process((replace_sm)pdu);
 }
Exemplo n.º 12
0
 public override void InternalDispatch(SmppSessionState state, SmppPdu pdu)
 {
     state.Process((deliver_sm_resp)pdu);
 }
Exemplo n.º 13
0
 public override void InternalDispatch(SmppSessionState state, SmppPdu pdu)
 {
     state.Process((generic_nack)pdu);
 }
Exemplo n.º 14
0
 public override void InternalDispatch(SmppSessionState state, SmppPdu pdu)
 {
     state.Process((alert_notification)pdu);
 }