コード例 #1
0
ファイル: EsmeSession.cs プロジェクト: xtoblizi/smpp.net
        /// <summary>
        /// This method sends a enquire_link packet synchronously over to the peer.
        /// </summary>
        /// <param name="pdu">enquire_link packet</param>
        /// <returns>enquire_link_resp response</returns>
        public enquire_link_resp EnquireLink(enquire_link pdu)
        {
            enquire_link_resp response = null;
            PduSyncronizer    sync     = AddWaitingPdu(pdu);

            if (sync != null)
            {
                if (IsBound && SendPdu(pdu))
                {
                    if (sync.WaitForResponse())
                    {
                        response = sync.PduResponse as enquire_link_resp;
                        if (response == null)
                        {
                            response = new enquire_link_resp(pdu.SequenceNumber, sync.PduResponse.Status);
                        }
                    }
                    else
                    {
                        response = new enquire_link_resp(pdu.SequenceNumber, StatusCodes.ESME_RINVEXPIRY);
                    }
                }
                else
                {
                    response = new enquire_link_resp(pdu.SequenceNumber, StatusCodes.ESME_RSUBMITFAIL);
                }
                FindAndRemoveWaitingPdu(pdu.SequenceNumber);
            }
            else
            {
                response = new enquire_link_resp(pdu.SequenceNumber, StatusCodes.ESME_RMSGQFUL);
            }

            return(response);
        }
コード例 #2
0
ファイル: EsmeSession.cs プロジェクト: xtoblizi/smpp.net
        /// <summary>
        /// This method sends a submit_sm packet synchronously over to the peer.
        /// </summary>
        /// <param name="pdu">submit_sm packet</param>
        /// <returns>submit_sm response</returns>
        public submit_sm_resp SubmitSm(submit_sm pdu)
        {
            submit_sm_resp response = null;
            PduSyncronizer sync     = AddWaitingPdu(pdu);

            if (sync != null)
            {
                if (IsBound && SendPdu(pdu))
                {
                    if (sync.WaitForResponse())
                    {
                        response = sync.PduResponse as submit_sm_resp;
                        if (response == null)
                        {
                            response = new submit_sm_resp(pdu.SequenceNumber, sync.PduResponse.Status);
                        }
                    }
                    else
                    {
                        response = new submit_sm_resp(pdu.SequenceNumber, StatusCodes.ESME_RINVEXPIRY);
                    }
                }
                else
                {
                    response = new submit_sm_resp(pdu.SequenceNumber, StatusCodes.ESME_RSUBMITFAIL);
                }
                FindAndRemoveWaitingPdu(pdu.SequenceNumber);
            }
            else
            {
                response = new submit_sm_resp(pdu.SequenceNumber, StatusCodes.ESME_RMSGQFUL);
            }

            return(response);
        }
コード例 #3
0
        /// <summary>
        /// This method sends a deliver_sm packet synchronously over to the peer.
        /// </summary>
        /// <param name="pdu">deliver_sm packet</param>
        /// <returns>deliver_sm response</returns>
        public deliver_sm_resp DeliverSm(deliver_sm pdu)
        {
            deliver_sm_resp rpdu = null;
            PduSyncronizer  evt  = AddWaitingPdu(pdu);

            if (IsBound && SendPdu(pdu))
            {
                SmppPdu pduR = evt.PduResponse;
                if ((pduR as deliver_sm_resp) != null)
                {
                    rpdu = (deliver_sm_resp)pduR;
                }
                else
                {
                    rpdu        = new deliver_sm_resp();
                    rpdu.Status = pduR.Status;
                }
            }
            else
            {
                FindAndRemoveWaitingPdu(pdu.SequenceNumber);
                rpdu        = new deliver_sm_resp();
                rpdu.Status = StatusCodes.ESME_RDELIVERYFAILURE;
            }
            return(rpdu);
        }
コード例 #4
0
ファイル: EsmeSession.cs プロジェクト: xtoblizi/smpp.net
        /// <summary>
        /// This method sends a bind_receiver packet synchronously over to the peer.
        /// </summary>
        /// <param name="pdu">bind_receiver packet</param>
        /// <returns>bind_receiver_resp</returns>
        public bind_receiver_resp BindReceiver(bind_receiver pdu)
        {
            bind_receiver_resp response = null;
            PduSyncronizer     sync     = AddWaitingPdu(pdu);

            if (sync != null)
            {
                if (SendPdu(pdu))
                {
                    if (sync.WaitForResponse())
                    {
                        response = sync.PduResponse as bind_receiver_resp;
                        if (response != null)
                        {
                            if (response.Status == StatusCodes.ESME_ROK)
                            {
                                base.CurrentState = new EsmeBoundRXSessionState(this);
                            }
                        }
                        else
                        {
                            response = new bind_receiver_resp(pdu.SequenceNumber, sync.PduResponse.Status);
                        }
                    }
                    else
                    {
                        response = new bind_receiver_resp(pdu.SequenceNumber, StatusCodes.ESME_RINVEXPIRY);
                    }
                }
                else
                {
                    response = new bind_receiver_resp(pdu.SequenceNumber, StatusCodes.ESME_RBINDFAIL);
                }
                FindAndRemoveWaitingPdu(pdu.SequenceNumber);
            }
            else
            {
                response = new bind_receiver_resp(pdu.SequenceNumber, StatusCodes.ESME_RMSGQFUL);
            }

            return(response);
        }