示例#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);
            }
        }
示例#2
0
        private static void OnSessionConnected(object sender, SmppEventArgs args)
        {
            // Test bind status?
            // Send Bind PDU to SMSC asynchronously
            Console.WriteLine("Successfully connected to SMSC. Now binding...");
            bind_transceiver bindPdu = new bind_transceiver("RON-HAY-LAP", "test", "",
                                                            new interface_version(),                                                                    // Default is version 3.4
                                                            new address_range());

            _smppSession.BeginBindTransceiver(bindPdu, new AsyncCallback(BindTransceiverCallback));
        }
示例#3
0
文件: Main.cs 项目: xtoblizi/smpp.net
        // Called when the connection to SMSC is established
        private void OnSessionConnected(object sender, SmppEventArgs args)
        {
            // Update the SMSC connection status and related controls
            SetSmscConnectionStatus(SmscConnectionStatus.Connected);

            // Send Bind PDU to SMSC asynchronously
            bind_transceiver bindPdu = new bind_transceiver(smscSystemId_, smscPassword_, "",
                                                            new interface_version(),    // Default is version 3.4
                                                            new address_range());

            bindPdu.SystemType = smscSystemType_;
            smppSession_.BeginBindTransceiver(bindPdu, new AsyncCallback(BindTransceiverCallback));
            SetSmscConnectionStatus(SmscConnectionStatus.Bound);
        }
示例#4
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);
        }
示例#5
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);
        }
示例#6
0
        /// <summary>
        /// This method invokes the BindTransceiver method asynchronously
        /// </summary>
        /// <param name="pdu">bind_transceiver PDU to send</param>
        /// <param name="callback">Asynch callback</param>
        /// <returns>IAsyncResult interface for monitoring</returns>
        public IAsyncResult BeginBindTransceiver(bind_transceiver pdu, AsyncCallback callback)
        {
            AsynchCall acr = new AsynchCall(callback, this);

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