質問

I am using jamaa-smpp to send sms. But I am not able to send more than 160 characters using the api. I am using the following link http://jamaasmpp.codeplex.com/

The code is as follows

 SmppConnectionProperties properties = _client.Properties;
  properties.SystemID = "test";
  properties.Password = "test1";
  properties.Port = 101; //IP port to use
  properties.Host = "..."; //SMSC host name or IP Address
  ....

Is it possible to send more than 160 character using that API.

役に立ちましたか?

解決

I found the solution it was there on the website discussion. I am posting it here so that one can find solution here.

I replaced the existing function in the TextMessage.cs (JamaaTech.Smpp.Net.Client).
The function name is IEnumerable<SendSmPDU> GetPDUs(DataCoding defaultEncoding)

 //protected override IEnumerable<SendSmPDU> GetPDUs(DataCoding defaultEncoding)
    //{
    //    //This smpp implementation does not support sending concatenated messages,
    //    //however, concatenated messages are supported on the receiving side.
    //    int maxLength = GetMaxMessageLength(defaultEncoding, false);
    //    byte[] bytes = SMPPEncodingUtil.GetBytesFromString(vText, defaultEncoding);
    //    //Check message size
    //    if(bytes.Length > maxLength)
    //    {
    //        throw new InvalidOperationException(string.Format(
    //            "Encoding '{0}' does not support messages of length greater than '{1}' charactors",
    //            defaultEncoding, maxLength));
    //    }
    //    SubmitSm sm = new SubmitSm();
    //    sm.SetMessageBytes(bytes);
    //    sm.SourceAddress.Address = vSourceAddress;
    //    sm.DestinationAddress.Address = vDestinatinoAddress;
    //    sm.DataCoding = defaultEncoding;
    //    if (vRegisterDeliveryNotification) { sm.RegisteredDelivery = RegisteredDelivery.DeliveryReceipt; }
    //    yield return sm;
    //}
    protected override IEnumerable<SendSmPDU> GetPDUs(DataCoding defaultEncoding)
    {
        SubmitSm sm = new SubmitSm();
        sm.SourceAddress.Address = vSourceAddress;
        sm.DestinationAddress.Address = vDestinatinoAddress;
        sm.DataCoding = defaultEncoding;
        if (vRegisterDeliveryNotification)
            sm.RegisteredDelivery = RegisteredDelivery.DeliveryReceipt;
        int maxLength = GetMaxMessageLength(defaultEncoding, false);
        byte[] bytes = SMPPEncodingUtil.GetBytesFromString(vText, defaultEncoding);
        if (bytes.Length > maxLength)
        {
            var SegID = new Random().Next(1000, 9999); 
            var messages = Split(vText, GetMaxMessageLength(defaultEncoding, true));
            var totalSegments = messages.Count;
            var udh = new Udh(SegID, totalSegments, 0);
            for (int i = 0; i < totalSegments; i++)
            {
                udh.MessageSequence = i + 1;
                sm.Header.SequenceNumber = PDUHeader.GetNextSequenceNumber(); 
                sm.SetMessageText(messages[i], defaultEncoding, udh);
                yield return sm;
            }
        }
        else
        {
            sm.SetMessageBytes(bytes);
            yield return sm;
        }
    }

    private static List<String> Split(string message, int maxPartLength)
    {
        var result = new List<String>();

        for (int i = 0; i < message.Length; i += maxPartLength)
        {
            var chunkSize = i + maxPartLength < message.Length ? maxPartLength : message.Length - i;
            var chunk = new char[chunkSize];
            message.CopyTo(i, chunk, 0, chunkSize);
            result.Add(new string(chunk));
        }
        return result;
    } 
ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top