首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >SMPP -接收消息

SMPP -接收消息
EN

Stack Overflow用户
提问于 2016-08-11 19:00:16
回答 1查看 1.1K关注 0票数 0

我是SMPP的新手,我正在使用JamatechSMPP (一个用于SMPP的开源.NET库)来连接到SMSC。我可以成功地发送消息,但是我无法接收。Jamatech帮助文档说,当收到消息但接收失败时,将引发一个名为"client_MessageReceived“的事件,我不确定如何在收到消息时引发该事件。

代码语言:javascript
复制
class UTSystem 
{
    private static SmppClient client;

UTSystem() 
{
    client = new SmppClient();
}

public static SmppClient ConnectToSMSC() 
{
    try 
    {
        client.Shutdown();

        SmppConnectionProperties properties = client.Properties;
        properties.SystemID = "xxxxxxxx";
        properties.Password = "xxxxxxx";
        properties.Port = xxxx; //IP port to use
        properties.Host = "xxxxxxxxxxx"; //SMSC host name or IP Address
        properties.SystemType = "SMPP";
        properties.DefaultServiceType = ServiceType.CELLULAR_MESSAGING;
        properties.AddressNpi = NumberingPlanIndicator.Unknown;
        properties.AddressTon = TypeOfNumber.Unknown;

        client.AutoReconnectDelay = 3000;

        client.KeepAliveInterval = 15000;

        //Start smpp client
        client.ForceConnect();

        return client;
    } 
    catch (Exception ex) 
    {
        Console.WriteLine(ex.Message);
        return client;
    }
}

public static void ReceiveSMS() 
{
    try 
    {
        ConnectToSMSC();

        client.MessageReceived += new EventHandler < MessageEventArgs > (client_MessageReceived);

    } 
    catch (Exception ex) {}
}

static public void client_MessageReceived(object sender, MessageEventArgs e) 
{
    //The event argument e contains more information about the received message

    TextMessage textMsg = e.ShortMessage as TextMessage; //This is the received text message

    int res = SaveMsg(textMsg.SourceAddress.ToString(), textMsg.Text.ToString());
}
EN

回答 1

Stack Overflow用户

发布于 2018-09-03 20:11:54

请确保您的smpp网关配置为接收SMS。应将其配置为收发器模式。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/38894498

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档