Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

礼物数据有重复,怎么去重? #83

Open
miraclestar opened this issue Jul 20, 2023 · 4 comments
Open

礼物数据有重复,怎么去重? #83

miraclestar opened this issue Jul 20, 2023 · 4 comments

Comments

@miraclestar
Copy link

[礼物] 游网络 : 棒棒糖 x 1
[礼物] 游网络 : 棒棒糖 x 1

只刷了一个棒棒糖,出现了2个

@ssochi
Copy link

ssochi commented Aug 2, 2023

private static int GetGiftCount(Gift gift) {
DouYinGift gift1 = (DouYinGift) gift;
GiftMessage giftMessage = gift1.giftMessage;

    if (giftMessage.getGroupId() == 0){

        if (giftMessage.getRepeatCount() == 0){
            LOGGER.error("giftMessage.getRepeatCount() == 0");
            LOGGER.error(giftMessage.getRepeatCount() + ":" + giftMessage.getGroupCount() + ":" + giftMessage.getTotalCount()
                    + ":" + giftMessage.getGroupId() + ":" + giftMessage.getGiftId());
        }
        return (int) giftMessage.getRepeatCount();
    }

    String uniqueId = gift.user().userId() + giftMessage.getGiftId() + giftMessage.getGroupId();

    giftGroupMap.putIfAbsent(uniqueId, new AtomicInteger(0));
    AtomicInteger atomicInteger = giftGroupMap.get(uniqueId);

    int currentCount;
    int count = (int) giftMessage.getRepeatCount();

    while (count > (currentCount = atomicInteger.get())){

        if (!atomicInteger.compareAndSet(currentCount,count)){
            continue;
        }

        return count - currentCount;
    }                   

    return 0;
}

@ssochi
Copy link

ssochi commented Aug 2, 2023

[礼物] 游网络 : 棒棒糖 x 1 [礼物] 游网络 : 棒棒糖 x 1

只刷了一个棒棒糖,出现了2个

老铁代码给你了,但是我现在经常遇到一个密集的时间点会丢很多礼物,不知道是啥原因导致的。。你有思路吗

@miraclestar
Copy link
Author

没遇到过呀,猜测网络或者处理速度不够

@scx567888 scx567888 reopened this Dec 13, 2023
@DREAM-XIN
Copy link

[礼物] 游网络 : 棒棒糖 x 1 [礼物] 游网络 : 棒棒糖 x 1
只刷了一个棒棒糖,出现了2个

老铁代码给你了,但是我现在经常遇到一个密集的时间点会丢很多礼物,不知道是啥原因导致的。。你有思路吗

我猜测可能是直播平台展示限制,例如10w+直播间,不可能把所有弹幕、礼物全部展示

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants