예제 #1
0
        /// <summary>
        /// This method processes the bind_receiver PDU and performs the bind to the session.
        /// </summary>
        /// <param name="pdu">Protocol Data Unit being processed</param>
        public override void Process(bind_receiver pdu)
        {
            // Build our response PDU
            bind_receiver_resp pduOut = new bind_receiver_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 SmscBoundRXSessionState(session_);
                }
                else
                {
                    session_.PeerSystemID = "";
                    session_.SmppVersion  = 0;
                }
                session_.SendPdu(pduOut);
            }
        }
예제 #2
0
        /// <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);
        }
예제 #3
0
        /// <summary>
        /// This method invokes the BindReceiver method asynchronously
        /// </summary>
        /// <param name="pdu">bind_receiver PDU to send</param>
        /// <param name="callback">Asynch callback</param>
        /// <returns>IAsyncResult interface for monitoring</returns>
        public IAsyncResult BeginBindReceiver(bind_receiver pdu, AsyncCallback callback)
        {
            AsynchCall acr = new AsynchCall(callback, this);

            return(acr.BeginInvoke(new BindReceiverDelegate(BindReceiver), new object[] { pdu }));
        }
예제 #4
0
 /// <summary>
 /// This processes the bind_receiver PDU
 /// </summary>
 /// <param name="pdu">Protocol Data Unit being processed</param>
 public virtual void Process(bind_receiver pdu)
 {
     throw new InvalidSmppStateException("Session is not in the proper state for a bind operation.");
 }
예제 #5
0
 /// <summary>
 /// This returns a specific error for the bind_receiver event; we are already bound!
 /// </summary>
 /// <param name="pdu">Protocol Data Unit</param>
 public override void Process(bind_receiver pdu)
 {
     session_.SendPdu(new bind_receiver_resp(pdu.SequenceNumber, StatusCodes.ESME_RALYBND));
 }