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; } }
/// <summary> /// Creates a <see cref="TextMessage"/> from a received <see cref="SingleDestinationPDU"/> /// </summary> /// <param name="pdu">The PDU from which a <see cref="TextMessage"/> is constructed</param> /// <returns>A <see cref="TextMessage"/> represening a text message extracted from the received PDU</returns> public static TextMessage CreateMessage(SingleDestinationPDU pdu) { //This version supports only text messages Udh udh = null; string message = null; pdu.GetMessageText(out message, out udh); TextMessage sms = null; //Check if the udh field is present if (udh != null) { sms = new TextMessage(udh.SegmentID, udh.MessageCount, udh.MessageSequence); } else { sms = new TextMessage(); } sms.Text = message == null ? "" : message; sms.SourceAddress = pdu.SourceAddress.Address; sms.DestinationAddress = pdu.DestinationAddress.Address; return sms; }
/// <summary> /// Creates a <see cref="TextMessage"/> from a received <see cref="SingleDestinationPDU"/> /// </summary> /// <param name="pdu">The PDU from which a <see cref="TextMessage"/> is constructed</param> /// <returns>A <see cref="TextMessage"/> represening a text message extracted from the received PDU</returns> public static TextMessage CreateMessage(SingleDestinationPDU pdu) { //This version supports only text messages Udh udh = null; string message = null; pdu.GetMessageText(out message, out udh); TextMessage sms = null; //Check if the udh field is present if (udh != null) { sms = new TextMessage(udh.SegmentID, udh.MessageCount, udh.MessageSequence); } else { sms = new TextMessage(); } sms.Text = message == null ? "" : message; sms.SourceAddress = pdu.SourceAddress.Address; sms.DestinationAddress = pdu.DestinationAddress.Address; return(sms); }