GithubHelp home page GithubHelp logo

Comments (10)

mistgc avatar mistgc commented on August 23, 2024 1

If you modify the following code in src/app.rs, can avoid losing messages occasionally.

let client2 = self.danmu_client.clone();
let recv_msg = tokio::spawn(async move {
    loop {
        client2.lock().await.receive().await;
        // tokio::time::sleep(Duration::from_secs_f32(0.3)).await;
        tokio::time::sleep(Duration::from_secs_f32(0.01)).await;
    }
});

So that's some sync problem?

Actually yes, because there are 2 tasks that need to manipulate the client, and the client be protected by Mutex. If we do not send a 'heartbeat' to the server within the 60s, the server would close the connection with us. So we have to sleep the receiving message task and release the Mutex protecting the client to make sure that the 'heartbeat' be sent within a reasonable time.

from bili-live-chat.

mistgc avatar mistgc commented on August 23, 2024

Yeah, I found this issue. Actually, if you use this to connect a live room that has a lot of audience, this will lose some messages. I will try to fix it in a couple of days.

from bili-live-chat.

mistgc avatar mistgc commented on August 23, 2024

I found I can't send danmaku in bilibili_live_tui sometimes but can do it in bili-live-chat.

That's weird!!!

bilibili_live_tui.1:

image

bilibili_live_tui.2:

image

bili-live-chat:

image

from bili-live-chat.

mistgc avatar mistgc commented on August 23, 2024

If you modify the following code in src/app.rs, can avoid losing messages occasionally.

let client2 = self.danmu_client.clone();
let recv_msg = tokio::spawn(async move {
    loop {
        client2.lock().await.receive().await;
        // tokio::time::sleep(Duration::from_secs_f32(0.3)).await;
        tokio::time::sleep(Duration::from_secs_f32(0.01)).await;
    }
});

from bili-live-chat.

futuretech6 avatar futuretech6 commented on August 23, 2024

If you modify the following code in src/app.rs, can avoid losing messages occasionally.

let client2 = self.danmu_client.clone();
let recv_msg = tokio::spawn(async move {
    loop {
        client2.lock().await.receive().await;
        // tokio::time::sleep(Duration::from_secs_f32(0.3)).await;
        tokio::time::sleep(Duration::from_secs_f32(0.01)).await;
    }
});

So that's some sync problem?

from bili-live-chat.

futuretech6 avatar futuretech6 commented on August 23, 2024

I send several messages using bilibili_live_tui, none of them fails. But I can't a single message using bili-live-chat, and there is no error message such as "发送弹幕失败".

from bili-live-chat.

mistgc avatar mistgc commented on August 23, 2024

And I found a possible reason that some messages can not be sent. That is caused by the data that do not be encoded by urlencode.

from bili-live-chat.

mistgc avatar mistgc commented on August 23, 2024

At the branch dev 95402a0, the sync problem had been solved.

from bili-live-chat.

futuretech6 avatar futuretech6 commented on August 23, 2024

At the branch dev 95402a0, the sync problem had been solved.

I test it using roomId 23141761, it is ok but the messages box are refreshed once many seconds rather then fetched immediately (possibly due to the message frequency is very high in that room)

from bili-live-chat.

mistgc avatar mistgc commented on August 23, 2024

I found that when messages are sent very frequently, the Danmaku Receiver in the BiLiBiLi web client also has this problem.

from bili-live-chat.

Related Issues (3)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.