Exemplo n.º 1
0
        private static void client_ConnectionStateChanged(object sender, ConnectionStateChangedEventArgs e)
        {
            switch (e.CurrentState)
            {
            case SmppConnectionState.Closed:
                //Connection to the remote server is lost
                //Do something here

                e.ReconnectInteval = 60000; //Try to reconnect after 1 min
                Console.WriteLine("Closed");
                break;
            case SmppConnectionState.Connected:
                //A successful connection has been established
                Console.WriteLine("Connected");

                TextMessage msg = new TextMessage();

                msg.DestinationAddress = "255455388333"; //Receipient number
                msg.SourceAddress = "255344338333"; //Originating number
                msg.Text = "Hello, this is my test message!";
                msg.RegisterDeliveryNotification = true; //I want delivery notification for this message

                client.SendMessage(msg);

                break;
            case SmppConnectionState.Connecting:
                //A connection attemp is still on progress
                Console.WriteLine("Connecting");
                break;
            }
        }
Exemplo n.º 2
0
        private void RaiseConnectionStateChangeEvent(SmppConnectionState newState, SmppConnectionState oldState)
        {
            if (ConnectionStateChanged == null)
            {
                return;
            }
            ConnectionStateChangedEventArgs e = new ConnectionStateChangedEventArgs(newState, oldState, vAutoReconnectDelay);

            ConnectionStateChanged(this, e);
            if (e.ReconnectInteval < 5000)
            {
                e.ReconnectInteval = 5000;
            }
            Interlocked.Exchange(ref vAutoReconnectDelay, e.ReconnectInteval);
        }