首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >在SMPP网关上组合接收消息部分

在SMPP网关上组合接收消息部分
EN

Stack Overflow用户
提问于 2021-11-08 07:02:01
回答 1查看 92关注 0票数 0

我使用Inetlab.SMPP 2.8.1 (基于许可原因)来实现SMPP网关。短消息与长文本必须分割成小部分。因此,我遵循文章并使用一个MessageComposer实例来组合连接的消息:

代码语言:javascript
复制
private void OnClientSubmitSm(object sender, SmppServerClient client, SubmitSm pdu)
{
    _composer.AddMessage(pdu);
    if (_composer.IsLastSegment(pdu))
    {
        string fullMessage = _composer.GetFullMessage(pdu);
        // do something
    }
}

其中_composerMessageComposer

但是代码会产生以下错误:

System.ArgumentNullException:值不能为空。(参数'key') 在System.Collections.Concurrent.ConcurrentDictionary2.ThrowKeyNullException() at System.Collections.Concurrent.ConcurrentDictionary2.TryGetValue(TKey key,TValue& value) 在Inetlab.SMPP.Common.DefaultComposerItemStore.TryGet(String键,ComposerItem& item) 在Inetlab.SMPP.Common.MessageComposer.IsLastSegmentTSmppMessage

注意,类似的代码适用于evDeliverSm事件。但是它不想处理传入的submit_sm PDU。

我做错了什么?我要做什么才能得到预期的结果呢?

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2021-11-08 10:09:06

使用evFullMessageReceived事件解决了这个问题,而不是检查消息段。因此,以下事件处理程序将按预期处理传入的SUBMIT_SM PDU:

代码语言:javascript
复制
// the method handles evClientSubmitSm event of SmppServer instance
private void OnClientSubmitSm(object sender, SmppServerClient client, SubmitSm pdu)
{
    try
    {
        _composer.AddMessage(pdu);
    }
    catch (Exception error)
    {
        pdu.Response.Header.Status = CommandStatus.ESME_RSUBMITFAIL;
        // log error
    }
}

// the method handles evFullMessageReceived event of MessageComposer instance
private void OnFullMessageReceived(object sender, MessageEventHandlerArgs arguments)
{
    SubmitSm pdu = null;
    SmppClientBase client = null;

    try
    {
        pdu = arguments.GetFirst<SubmitSm>();
        client = pdu.Client;
        string fullMessage = arguments.Text;
        // save message
    }
    catch (Exception error)
    {
        pdu.Response.Header.Status = CommandStatus.ESME_RSUBMITFAIL;
        // log error
    }
}

// the method handles evFullMessageTimeout event of MessageComposer instance
private void OnFullMessageTimeout(object sender, MessageEventHandlerArgs arguments)
{
    SubmitSm pdu = arguments.GetFirst<SubmitSm>();
    // log warning
}
票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/69879658

复制
相关文章

相似问题

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