Rantanen / node-mumble

Mumble client in Node.js
MIT License
155 stars 48 forks source link

User names in voice events become null when muting or moving channel #88

Closed mikesmiffy128 closed 8 years ago

mikesmiffy128 commented 8 years ago

Hi! First of all, thanks for making this library; it's working great so far!

I've done a bit of looking through the API and there doesn't seem to be a way of getting a list of everyone currently transmitting audio (my goal is to have a little web-based widget that will show all the people currently talking). The way I've thought of going about it is to get the audio streams of each user in a channel, then check if the volume is above a certain level. The problem with this is I'd then have to keep track of everyone joining and leaving, and also open a lot of streams at the same time.

I'm just wondering if there's an easier way I've overlooked, or if something could be implemented. Or is this just a Mumble limitation?

Rantanen commented 8 years ago

Glad to hear!

Just checked - seems this part is badly documented and probably needs some enhancements.

You have two options. Either listen to 'voice-start' and 'voice-end' events or alternatively use the 'voice-frame' event. Looking at the documentation, these don't seem to be documented there, but they do exist and can be seen in the code.

The first one will give you quick event based access that should make "display icon"/"hide icon" actions easy to implement, but it won't let you query the connection for a snapshot of "Who is talking at the moment?".

You can also take a look at the following project, which should implement something similar: https://github.com/Rantanen/mumble-debugger

Specifically it seems to be using a hybrid approach where voice-frames are used to flag the user as talking and voice-end events are used to clear that flag. This was probably to make sure that users are shown as talking even if a certain web client joins the session halfway into a conversation and misses on the voice-start event.

mikesmiffy128 commented 8 years ago

Thanks, that worked perfectly! :+1:

mikesmiffy128 commented 8 years ago

Hmm... it seems like there's either a bug or I'm doing something wrong. Whenever I do some kind of action (mute / unmute, move channel, etc.), the name value in each event suddenly becomes null. If either I rejoin the server or I reconnect the bot it seems to fix itself. Any idea what might cause that?

Rantanen commented 8 years ago

Which event are you using?

mikesmiffy128 commented 8 years ago

Currently voice-start to show the name in the list and voice-end to remove it. There are another couple of layers of event passing as well but I'm guessing they're not the problem since I'm just directly copying fields from one object to another.

mikesmiffy128 commented 8 years ago

So, I kind of forgot all about this for a while, but I just tried switching to the voice-frame method and apparently the null username issue is still persisting (although it's better anyway so it wasn't waste of time). It would be great to figure out any kind of workaround for this. I've pretty much no idea what's causing this to happen.

Rantanen commented 8 years ago

Dammit. :)

I think there's been multiple people reporting this now, but I've yet to be able to replicate it myself. I'd love a piece of code and instructions to reproduce this issue.

The annoying bit is that I'm guessing the actual bug is something stupid simple.

mikesmiffy128 commented 8 years ago

So, I've been doing other things for the last couple of days; I have no attention span... but anyway...

I've actually been trying to make a NodeCG bundle. I've not really done much of it yet so the whole thing is a bit messy and probably half-broken, but the bit that's giving me trouble is something to this effect:

mumble.on("voice-frame", function(frames) {
    for (var f in frames) {
        if (frames[f].user) {
            // When stuff starts to break, this will start dumping stuff to the console.
            // Interestingly, most of the data is intact, just none of the ID/name related stuff.
            if (frames[f].user.name === null) {
                console.log(frames[f].user)
            }

            // This is the actual code that I'd use assuming I can help solve this issue :)
            if (frames[f].user.talking) {
                nodecg.sendMessage("user-talking", {name: frames[f].user.name, state: true})
            }
        }
    }
})

Hopefully this helps to some extent! :pray:

Rantanen commented 8 years ago

Ended up testing status messages, ie. self mute/deaf/etc.

Those reset the names and such. This issue is now fixed - hopefully I didn't introduce other issues in its place.

mikesmiffy128 commented 8 years ago

Yay! Thank you. :+1: On 13 Apr 2016 21:25, "Mikko Rantanen" notifications@github.com wrote:

Ended up testing status messages, ie. self mute/deaf/etc.

Those reset the names and such. This issue is now fixed - hopefully I didn't introduce other issues in its place.

— You are receiving this because you modified the open/close state. Reply to this email directly or view it on GitHub https://github.com/Rantanen/node-mumble/issues/88#issuecomment-209631751