Exemplo n.º 1
0
        /// <summary>
        /// This method processes the bind_transceiver PDU and performs the bind to the session.
        /// </summary>
        /// <param name="pdu">Protocol Data Unit being processed</param>
        public override void Process(bind_transceiver pdu)
        {
            // Build our response PDU
            bind_transceiver_resp pduOut = new bind_transceiver_resp(pdu.SequenceNumber, session_.LocalSystemID);

            // Assign the peer id and version
            session_.PeerSystemID = pdu.SystemID;
            session_.SmppVersion  = pdu.InterfaceVersion;

            // Fire the bind event to the session owner
            SmppEventArgs ea = new SmppEventArgs(session_, pdu, pduOut);

            if (session_.FireEvent(EventType.Bind, ea))
            {
                // If the session owner indicated it's ok to bind, then perform the binding.
                if (pduOut.Status == StatusCodes.ESME_ROK)
                {
                    session_.CurrentState = new SmscBoundTRXSessionState(session_);
                }
                else
                {
                    session_.PeerSystemID = "";
                    session_.SmppVersion  = 0;
                }
                session_.SendPdu(pduOut);
            }
        }
 /// <summary>
 /// This method processes the bind_transceiver_resp PDU and performs the bind to the session.
 /// </summary>
 /// <param name="pdu">Protocol Data Unit being processed</param>
 public override void Process(bind_transceiver_resp pdu)
 {
     if (pdu.Status == StatusCodes.ESME_ROK)
     {
         this.session.CurrentState = new EsmeBoundTXSessionState(this.session);
         this.session.FireEvent(EventType.Bound, new SmppEventArgs(this.session, pdu.OriginalRequest, pdu));
     }
 }
Exemplo n.º 3
0
        // Used to catch and display binding issues
        private void BindTransceiverCallback(IAsyncResult ar)
        {
            // Process the bind result
            EsmeSession           session  = (EsmeSession)ar.AsyncState;
            bind_transceiver_resp bindResp = session.EndBindTransceiver(ar);

            if (bindResp.Status != StatusCodes.ESME_ROK)
            {
                MessageBox.Show("Error binding to SMSC: " + bindResp.Status.ToString());
//                Close();
            }
        }
Exemplo n.º 4
0
        private static void BindTransceiverCallback(IAsyncResult ar)
        {
            // Process the bind result
            EsmeSession           session  = (EsmeSession)ar.AsyncState;
            bind_transceiver_resp bindResp = session.EndBindTransceiver(ar);

            if (bindResp.Status != StatusCodes.ESME_ROK)
            {
                // Display binding error
                Console.WriteLine("Error binding to SMSC: " + bindResp.Status.ToString());

                // Drop the session which will cause a reconnect
                _smppSession.Close();
            }
        }
Exemplo n.º 5
0
        /// <summary>
        /// This method sends a bind_transceiver packet synchronously over to the peer.
        /// </summary>
        /// <param name="pdu">bind_transceiver packet</param>
        /// <returns>bind_transceiver_resp</returns>
        public bind_transceiver_resp BindTransceiver(bind_transceiver pdu)
        {
            bind_transceiver_resp response = null;
            PduSyncronizer        sync     = AddWaitingPdu(pdu);

            if (sync != null)
            {
                if (SendPdu(pdu))
                {
                    if (sync.WaitForResponse())
                    {
                        response = sync.PduResponse as bind_transceiver_resp;
                        if (response != null)
                        {
                            if (response.Status == StatusCodes.ESME_ROK)
                            {
                                base.CurrentState = new EsmeBoundTRXSessionState(this);
                            }
                        }
                        else
                        {
                            response = new bind_transceiver_resp(pdu.SequenceNumber, sync.PduResponse.Status);
                        }
                    }
                    else
                    {
                        response = new bind_transceiver_resp(pdu.SequenceNumber, StatusCodes.ESME_RINVEXPIRY);
                    }
                }
                else
                {
                    response = new bind_transceiver_resp(pdu.SequenceNumber, StatusCodes.ESME_RBINDFAIL);
                }
                FindAndRemoveWaitingPdu(pdu.SequenceNumber);
            }
            else
            {
                response = new bind_transceiver_resp(pdu.SequenceNumber, StatusCodes.ESME_RMSGQFUL);
            }
            return(response);
        }
Exemplo n.º 6
0
        private void OnBind(object sender, SmppEventArgs ea)
        {
            SmppPdu pdu = ea.PDU;

            if ((pdu as bind_receiver) != null || (pdu as bind_transmitter) != null)
            {
                ea.ResponsePDU.Status = StatusCodes.ESME_RINVCMDID;
            }
            else
            {
                bind_transceiver btpdu = (bind_transceiver)pdu;
                if (btpdu.Password != password_)
                {
                    ea.ResponsePDU.Status = StatusCodes.ESME_RINVPASWD;
                    return;
                }

                bind_transceiver_resp resp = (bind_transceiver_resp)ea.ResponsePDU;
                resp.InterfaceVersion = (byte)supportedVersion_;
            }

            // Update the listview.
            new System.Threading.Timer(new TimerCallback(UpdateListItem), ea.Session.Tag, 100, Timeout.Infinite);
        }
Exemplo n.º 7
0
 /// <summary>
 /// This processes the bind_transceiver_resp PDU
 /// </summary>
 /// <param name="pdu">Protocol Data Unit being processed</param>
 public virtual void Process(bind_transceiver_resp pdu)
 {
     throw new InvalidSmppStateException("Session is not in the proper state for a bind operation.");
 }