XMPPFramework - 获取重复消息

发布于 2024-12-27 00:27:11 字数 244 浏览 1 评论 0原文

我正在使用适用于 iOS 的 XMPPFramework。

我的问题是,当我加入一个房间,然后离开它,然后再次加入它时,我会收到来自该房间的消息,或者该房间内的私人消息两次,如果我离开它并再次加入它,我会收到 3 次,依此类推。

有人告诉我,我可能会注册多个代表而不是删除它们,但如果我这样做,我就是不小心这样做了,而且我不太确定这是在哪里发生的。 谁能帮忙看看这是哪里发生的吗?也许一个例子可以帮助我在代码中找到它。

谢谢。

I'm using the XMPPFramework for iOS.

My problem is that when I join a room, then leave it, and join it again I get messages from that room, or private messages within that room twice, If I leave it and join it again I receive then 3 times, and so on.

I've been told that I might be registering multiple delegates and not removing them, but If I'm doing that I'm doing it accidentally and I'm not really sure where is this happening.
Could anyone help finding where is this happening? Maybe an example would help me finding it in my code.

Thanks.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

流年里的时光 2025-01-03 00:27:11

以防万一有人想知道。

离开房间的正确方法是执行这组函数:

    [xmppRoom leaveRoom];
    [xmppRoom deactivate];
    [xmppRoom removeDelegate:self];

Just in case someone likes to know.

The right way to leave a room is to do this set of functions:

    [xmppRoom leaveRoom];
    [xmppRoom deactivate];
    [xmppRoom removeDelegate:self];
独享拥抱 2025-01-03 00:27:11

我认为 RemoteTimestamp 值有问题。我通过在文件中添加解决方法解决了该问题:
Extensions/XEP-0045/CoreDataStorage/XMPPRoomCoreDataStorage.m

之前:

- (BOOL)existsMessage:(XMPPMessage *)message forRoom:(XMPPRoom *)room stream:(XMPPStream    *)xmppStream
{
    NSDate *remoteTimestamp = [message delayedDeliveryDate];

    if (remoteTimestamp == nil)
    {   
    return NO;
    }

    NSManagedObjectContext *moc = [self managedObjectContext];
    ......
}

之后:

 - (BOOL)existsMessage:(XMPPMessage *)message forRoom:(XMPPRoom *)room stream:(XMPPStream *)xmppStream
{
    NSDate *remoteTimestamp = [message delayedDeliveryDate];

    if (remoteTimestamp == nil)
    {   
             return NO;
    }

    remoteTimestamp = nil;
    NSManagedObjectContext *moc = [self managedObjectContext];
    ......
 }

I thing there is a problem with remoteTimestamp value. I solve the problem by add workaround in file:
Extensions/XEP-0045/CoreDataStorage/XMPPRoomCoreDataStorage.m

before:

- (BOOL)existsMessage:(XMPPMessage *)message forRoom:(XMPPRoom *)room stream:(XMPPStream    *)xmppStream
{
    NSDate *remoteTimestamp = [message delayedDeliveryDate];

    if (remoteTimestamp == nil)
    {   
    return NO;
    }

    NSManagedObjectContext *moc = [self managedObjectContext];
    ......
}

after:

 - (BOOL)existsMessage:(XMPPMessage *)message forRoom:(XMPPRoom *)room stream:(XMPPStream *)xmppStream
{
    NSDate *remoteTimestamp = [message delayedDeliveryDate];

    if (remoteTimestamp == nil)
    {   
             return NO;
    }

    remoteTimestamp = nil;
    NSManagedObjectContext *moc = [self managedObjectContext];
    ......
 }
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文