如何使用DevShock Smpp发送有效载荷消息

时间:2019-07-09 17:13:16

标签: c# smpp

在一个旧项目中,我与DevShock.Smpp进行了SMSC集成。现在对该工具的支持不再可用,我遇到了必须发送PayLoad SMS的情况。

下面是我的代码

private static SmppSubmitSmRes Sendbin(byte[] bbin, bool multiMsg, string aNumber, string bNumber, bool isUniCode, long messageType, SmppConnection _mySmppClient)
    {
        SmppSubmitSmReq.BodyPdu reqSubmitSm = new SmppSubmitSmReq.BodyPdu
        {
            EsmClass = multiMsg ? new BitBuilder(Convert.ToByte(0x40)) : new BitBuilder(Convert.ToByte(0x0))
        };

        //Dim ResSubmit_Sm As SmppSubmitSmRes
        // ReqSubmit_Sm.ShortMessage.SetValue(bbin)
        //if it is unicode use 0x08 like for arabic or other unicode lang.
        if (isUniCode)
        {
            reqSubmitSm.ShortMessage.DataCoding = messageType == 1 ? SmppDataCoding.FromValue(24) : SmppDataCoding.Unicode;
            //reqSubmitSm.ShortMessage.DataCoding = SmppDataCoding.Unicode;
            //.FromValue(CByte(&H8))
            reqSubmitSm.SourceAddressNpi = new BitBuilder(1).Value;
        }
        else
        {
            reqSubmitSm.SourceAddressNpi = Convert.ToByte(0);
            reqSubmitSm.ShortMessage.DataCoding = SmppDataCoding.Default;
            reqSubmitSm.ShortMessage.DataCoding = messageType == 1 ? SmppDataCoding.FromValue(240) : SmppDataCoding.Default;
        }
        if (IsNumeric(aNumber))
        {
            reqSubmitSm.SourceAddressTon = isUniCode ? new BitBuilder(2).Value : (byte)0;
        }
        else
        {
            reqSubmitSm.SourceAddressTon = Convert.ToByte(5);
        }
        reqSubmitSm.DestinationAddressTon = Convert.ToByte(1);
        reqSubmitSm.DestinationAddressNpi = Convert.ToByte(1);
        reqSubmitSm.DestinationAddress = bNumber;
        reqSubmitSm.SourceAddress = aNumber;
        reqSubmitSm.ShortMessage.Value = bbin;
        reqSubmitSm.SourceAddress = aNumber;

        if (true)//delivery
        {
            reqSubmitSm.RegisteredDelivery = new BitBuilder(1);
        }
        var submitResponse = _mySmppClient.SubmitSm(new SmppSubmitSmReq(reqSubmitSm));
        return submitResponse;
    }

1 个答案:

答案 0 :(得分:0)

如果可以,请切换并使用INTELAB 出色的解决方案,并在论坛上提供强大的支持 inetlab support