Exemplo n.º 1
0
        /// <summary>
        /// This method is invoked when a new inbound socket hits our server.  We will create a new
        /// SMPP session object to manage the socket and begin communicating with the ESME session.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="args"></param>
        protected void OnStartSession(object sender, SocketEventArgs args)
        {
            ConnectEventArgs connEv = (ConnectEventArgs)args;
            SocketClient     scNew  = connEv.Client;

            // Create a new SMPP session to manage this connection.
            SmscSession newSession = new SmscSession(this, scNew, systemid_);

            // Back-link the session
            scNew.Tag = newSession;

            // Notify anyone who wants to know
            SmppConnectEventArgs sce = new SmppConnectEventArgs(scNew.Address, newSession);

            if (OnNewSession != null)
            {
                OnNewSession(this, sce);
            }
            if (!sce.AllowConnection)
            {
                scNew.Close(true);
            }
            else
            {
                scNew.OnEndSession += OnEndClientSession;
                lock (clients_)
                {
                    clients_.Add(newSession);
                }
            }
        }
Exemplo n.º 2
0
        private void OnNewSession(object sender, SmppEventArgs ea)
        {
            SmppConnectEventArgs ce = (SmppConnectEventArgs)ea;

            // Get the session information.
            IPAddress ipAddr = ce.Address;

            AddLogText(StatusCode.Session, string.Format("Connection from {0} accepted.", ipAddr.ToString()));

            // Get the session and establish our event handlers.
            SmscSession sess = (SmscSession)ce.Session;

            sess.OnPreprocessPdu     += OnPreprocessPdu;
            sess.OnPostprocessPdu    += OnPostprocessPdu;
            sess.OnBind              += OnBind;
            sess.OnSubmitSm          += OnSubmitSm;
            sess.OnQuerySm           += OnQuerySm;
            sess.OnCancelSm          += OnCancelSm;
            sess.OnUnbind            += OnUnbind;
            sess.OnError             += OnError;
            sess.OnSessionDisconnect += OnDisconnect;

            // Add the session to our listview
            new SessionListViewItem(lvSessions, sess);
            EnableGenerateSmsButton(true);
        }