/// <summary> /// Sends an SMS message synchronouslly, possibly splitting it on multiple PDUs /// using the specified segmentation & reassembly method. /// </summary> /// <param name="pdu">The pdu.</param> /// <param name="method">The method.</param> /// <returns>The list of messageIds assigned by remote party to each submitted PDU.</returns> public IEnumerable <string> Send(SmppSubmitSm pdu, SmppSarMethod method) { var requests = SmppUtil.SplitLongMessage(pdu, method, GetRandomByte()).Cast <SmppRequest>(); var responses = SendRequests(requests); if (responses.Any(x => (x is SmppGenericNackResp))) { var nack = responses.First(x => x is SmppGenericNackResp); var idx = responses.IndexWhere(x => x == nack); var req = requests.ElementAt(idx); var msg = string.Format("SMPP PDU was rejected by remote party. (error: {0})", nack.CommandStatus); throw new SmppRemoteException(msg, req, nack); } if (responses.Any(x => x.CommandStatus != 0)) { var res = responses.First(x => x.CommandStatus != 0); var idx = responses.IndexWhere(x => x == res); var req = requests.ElementAt(idx); var msg = string.Format("SMPP Request returned an error status. (code: {0})", res.CommandStatus); throw new SmppRemoteException(msg, req, res); } return(responses.OfType <SmppSubmitSmResp>().Select(x => x.MessageId).ToArray()); }
public void Can_Fragment_Using_Udh(int length, DataCoding coding, int segmentsNumber) { var message = new String(Enumerable.Repeat('A', length).ToArray()); var submitSm = new SmppSubmitSm() { DataCoding = coding, ShortMessage = message, }; var segments = SmppUtil.SplitLongMessage(submitSm, SmppSarMethod.UserDataHeader, 0x1); Assert.AreEqual(segmentsNumber, segments.Count()); }