private void server_evClientSubmitSm(object sender, SmppServerClient client, SubmitSm data) { long messageId = Interlocked.Increment(ref messageIdCounter); // You can set your own MessageId data.Response.MessageId = messageId.ToString(); _log.Info("Client {0} sends message From:{1}, To:{2}, Text: {3}", client.RemoteEndPoint, data.SourceAddress, data.DestinationAddress, data.GetMessageText(client.EncodingMapper)); _messageComposer.AddMessage(data); // Set unsuccess response status //data.Response.Status = CommandStatus.ESME_RSUBMITFAIL; if (data.SMSCReceipt != SMSCDeliveryReceipt.NotRequested) { //Send Delivery Receipt when required string messageText = data.GetMessageText(client.EncodingMapper); var dlrBuilder = SMS.ForDeliver() .From(data.DestinationAddress) .To(data.SourceAddress) .Receipt(new Receipt { DoneDate = DateTime.Now, State = MessageState.Delivered, MessageId = data.Response.MessageId, ErrorCode = "0", SubmitDate = DateTime.Now, Text = messageText.Substring(0, Math.Min(20, messageText.Length)) }); if (data.DataCoding == DataCodings.UCS2) { //short_message field cannot contain user data longer than 255 octets, //therefore for UCS2 encoding we are sending DLR in message_payload parameter dlrBuilder.MessageInPayload(); } client.Deliver(dlrBuilder).ConfigureAwait(false); } }
private void client_evDeliverSm(object sender, DeliverSm data) { try { //Check if we received Delivery Receipt if (data.MessageType == MessageTypes.SMSCDeliveryReceipt) { //Get MessageId of delivered message string messageId = data.Receipt.MessageId; MessageState deliveryStatus = data.Receipt.State; } else { // Receive incoming message and try to concatenate all parts if (data.Concatenation != null) { _composer.AddMessage(data); _log.Info("DeliverSm part received : Sequence: {0} SourceAddr: {1} Concatenation ( {2} ) Coding: {3} Text: {4}", data.Header.Sequence, data.SourceAddress, data.Concatenation, data.DataCoding, _client.EncodingMapper.GetMessageText(data)); if (_composer.IsLastSegment(data)) { string fullMessage = _composer.GetFullMessage(data); _log.Info("Full message: " + fullMessage); } } else { _log.Info("DeliverSm received : Sequence: {0} SourceAddr : {1} Coding : {2} MessageText : {3}", data.Header.Sequence, data.SourceAddress, data.DataCoding, _client.EncodingMapper.GetMessageText(data)); } } } catch (Exception ex) { data.Response.Header.Status = CommandStatus.ESME_RX_T_APPN; _log.Error("Failed to process DeliverSm", ex); } // </ReceiveMessage> }
private void client_evDeliverSm(object sender, DeliverSm data) { try { //Check if we received Delivery Receipt if (data.MessageType == MessageTypes.SMSCDeliveryReceipt) { //Get MessageId of delivered message string messageId = data.Receipt.MessageId; MessageState deliveryStatus = data.Receipt.State; _log.Info("Delivery Receipt received: {0}", data.Receipt.ToString()); } else { // Receive incoming message and try to concatenate all parts if (data.Concatenation != null) { _messageComposer.AddMessage(data); _log.Info("DeliverSm part received: Sequence: {0}, SourceAddress: {1}, Concatenation ( {2} )" + " Coding: {3}, Text: {4}", data.Header.Sequence, data.SourceAddress, data.Concatenation, data.DataCoding, _client.EncodingMapper.GetMessageText(data)); } else { _log.Info("DeliverSm received : Sequence: {0}, SourceAddress: {1}, Coding: {2}, Text: {3}", data.Header.Sequence, data.SourceAddress, data.DataCoding, _client.EncodingMapper.GetMessageText(data)); } // Check if an ESME acknowledgement is required if (data.Acknowledgement != SMEAcknowledgement.NotRequested) { // You have to clarify with SMSC support what kind of information they request in ESME acknowledgement. string messageText = data.GetMessageText(_client.EncodingMapper); var smBuilder = SMS.ForSubmit() .From(data.DestinationAddress) .To(data.SourceAddress) .Coding(data.DataCoding) .ConcatenationInUDH(_client.SequenceGenerator.NextReferenceNumber()) .Set(m => m.MessageType = MessageTypes.SMEDeliveryAcknowledgement) .Text(new Receipt { DoneDate = DateTime.Now, State = MessageState.Delivered, // MessageId = data.Response.MessageId, ErrorCode = "0", SubmitDate = DateTime.Now, Text = messageText.Substring(0, Math.Min(20, messageText.Length)) }.ToString() ); _client.Submit(smBuilder).ConfigureAwait(false); } } } catch (Exception ex) { data.Response.Header.Status = CommandStatus.ESME_RX_T_APPN; _log.Error(ex, "Failed to process DeliverSm"); } }
private void client_evDeliverSm(object sender, DeliverSm data) { _composer.AddMessage(data); }