c# - 如何设置 submit sm 让客户端使用它在 jamaa smpp 中的属性来发送消息?

标签 c# smpp

我正在使用 jamaa-smpp 发送消息。它有效,但发件人 ID 是 00000 而不是我想要的名称。我将 TONNPI 用于在提交 sm 中启用字母数字发件人,如下面的代码所示,但它仍然是 00000。我无法将 sm 链接到客户端发送消息时。

 public partial class WebForm1 : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {

        }

        protected void ss_Click(object sender, EventArgs e)
        {


            var sm = new SubmitSm();


            sm.SourceAddress.Ton = JamaaTech.Smpp.Net.Lib.TypeOfNumber.Aphanumeric;
            sm.SourceAddress.Npi = JamaaTech.Smpp.Net.Lib.NumberingPlanIndicator.ISDN;

            sm.DestinationAddress.Ton = JamaaTech.Smpp.Net.Lib.TypeOfNumber.International;
            sm.DestinationAddress.Npi = JamaaTech.Smpp.Net.Lib.NumberingPlanIndicator.ISDN;

            TextMessage msg = new TextMessage();

            msg.DestinationAddress ="96565565655556"; //Receipient number
            msg.SourceAddress = "NYCOMPANYNAME"; //Originating number

            msg.Text = "text text text text";
            msg.RegisterDeliveryNotification = true; //I want delivery notification for this message


            SmppClient client = GetSmppClient();

            client.BeginSendMessage(msg, SendMessageCompleteCallback, client);
        }


        private 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
                    break;
                case SmppConnectionState.Connected:
                    //A successful connection has been established
                    break;
                case SmppConnectionState.Connecting:
                    //A connection attemp is still on progress
                    break;
            }
        }
        private SmppClient GetSmppClient()
        {
            SmppClient client = new SmppClient();
            System.Threading.Thread.Sleep(9000);
            SmppConnectionProperties properties = client.Properties;
            properties.SystemID = "id";
            properties.Password = "pass";
            properties.Port = xxxxx; //IP port to use
            properties.Host = "x.x.x.x"; //SMSC host name or IP Address
            properties.SystemType = "SMPP";
            properties.DefaultServiceType = "SMPP";
            client.AutoReconnectDelay = 3000;
            client.KeepAliveInterval = 15000;
            client.Start();
            System.Threading.Thread.Sleep(9000);
            return client;
        }

        private static void SendMessageCompleteCallback(IAsyncResult result)
        {
            try
            {
                SmppClient client = (SmppClient)result.AsyncState;
                client.EndSendMessage(result);
            }
            catch (Exception e)
            {

            }
        }

    }

我希望发件人名称是 MYCOMPANYNAME 而不是 00000000。

最佳答案

您需要将“NPI”设置为未知,将“ton”设置为字母数字和

client.Properties.SourceAddress = "COMPANYNAME";  
client.SourceAddress.Ton = JamaaTech.Smpp.Net.Lib.TypeOfNumber.Alphanumeric;
client.SourceAddress.Npi=JamaaTech.Smpp.Net.Lib.NumberingPlanIndicator.Unknown;

不是 msg.SourceAddress = "MYCOMPANYNAME";

希望对您有所帮助。如果您觉得此答案有用,请标记。

关于c# - 如何设置 submit sm 让客户端使用它在 jamaa smpp 中的属性来发送消息?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56336677/

相关文章:

c# - 查找未等待的异步方法调用

ruby - 在 ruby​​-smpp 中使用 Eventmachine 和 EM-Redis 发送消息

c# - C#调试时 '~'是什么意思?

c# - 点击后退按钮时如何捕捉事件?

Java SMPP实现接收短信

mysql - Kannel Sqlbox 不工作(尝试连接到 SQL Server 而不是 MySQL)?

c# - 如何使用 SMPP 和 C# 从 SMSC 获取发送报告

java - 免费在线 SMPP 服务器

c# - Accord.Net 二项式概率质量函数结果与 Excel 结果不同

c# - 立即更新列表框