Example #1
0
        public mainForm()
        {
            InitializeComponent();

            // Get the default settings from our configuration file
            smscAddress_                 = GetAppSetting("SmscAddress", "127.0.0.1");
            smscPort_                    = GetAppSettingInt("SmscPort", 8080);
            smscSystemId_                = GetAppSetting("SystemId", Environment.MachineName);
            smscPassword_                = GetAppSetting("Password", "");
            smscSystemType_              = GetAppSetting("SystemType", "");
            submitServiceType_           = GetAppSetting("ServiceType", "");
            enquireLinkSeconds_          = GetAppSettingInt("EnquireLinkSeconds", 30);
            destinationAdrPrefix_        = GetAppSetting("DestinationAddressPrefix", "1");
            submitResponseMessageIdBase_ = GetAppSettingInt("SubmitResponseMessageIdBase", 10);

            // Create the ESME Smpp session - default version is 3.4
            smppSession_             = new EsmeSession(smscSystemId_);
            smppSession_.SmppVersion = SmppVersion.SMPP_V34;

            // Hook up all events we need
            smppSession_.OnSessionConnected    += OnSessionConnected;
            smppSession_.OnSessionDisconnected += OnSessionDisconnected;
            smppSession_.OnBound     += OnSessionBound;
            smppSession_.OnDeliverSm += OnDeliverSm;
        }
Example #2
0
        private void SubmitSmCallback(IAsyncResult ar)
        {
            if (InvokeRequired)
            {
                BeginInvoke((SubmitSmCallbackHandler)SubmitSmCallback, ar);
                return;
            }
            // Process the send/submit result
            EsmeSession    session    = (EsmeSession)ar.AsyncState;
            submit_sm_resp submitResp = session.EndSubmitSm(ar);

            // Update the message # in the message list using the sequence #
            string status = "Pending";

            if (submitResp.Status != StatusCodes.ESME_ROK)
            {
                MessageBox.Show("Error sending message: " + submitResp.Status);
                UpdateSentMessageId(submitResp.SequenceNumber, "******", "Error: " + submitResp.Status);
                return;
            }
            // Some carriers submit_sm message ID are in hex - convert to decimal since delivery receipt is in decimal
            string decimalMessageId = Convert.ToInt64(submitResp.MessageID, submitResponseMessageIdBase_).ToString();

            UpdateSentMessageId(submitResp.SequenceNumber, decimalMessageId, status);

            // Re-enable the Send button...
            btnSendMessage.Enabled = true;
        }
Example #3
0
        private static void SubmitSmCallback(IAsyncResult ar)
        {
            // Process the send/submit result
            EsmeSession    session    = (EsmeSession)ar.AsyncState;
            submit_sm_resp submitResp = session.EndSubmitSm(ar);

            Console.WriteLine(string.Format("Submit short message result: {0}, message id: {1}",
                                            submitResp.Status, submitResp.MessageID));
        }
Example #4
0
 private void socket_OnStartSession(object sender, SocketEventArgs args)
 {
     this.socket     = ((ConnectEventArgs)args).Client;
     this.session    = new EsmeSession(this, this.socket);
     this.socket.Tag = this.session;
     if (Connected != null)
     {
         Connected(this, new SmppConnectEventArgs(this.socket.Address, this.session));
     }
 }
Example #5
0
        private void EnquireLinkCallback(IAsyncResult ar)
        {
            // Process the enquire link result
            EsmeSession       session     = (EsmeSession)ar.AsyncState;
            enquire_link_resp enquireResp = session.EndEnquireLink(ar);

            if (enquireResp.Status != StatusCodes.ESME_ROK)
            {
                MessageBox.Show("Error sending enquire link to SMSC: " + enquireResp.Status.ToString());
            }
        }
Example #6
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();
            }
        }
Example #7
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();
            }
        }
Example #8
0
 /// <summary>
 /// Constructor for the open session state
 /// </summary>
 /// <param name="sess"></param>
 public EsmeOpenSessionState(EsmeSession session)
 {
     this.session = session;
 }