Rantanen / node-mumble

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

how to self mute / self deaf? #73

Closed Jrawke closed 8 years ago

Jrawke commented 8 years ago

Hello,

Sorry for the basic question, but what is the API call for self muting / self deafening? I couldn't find it in the wiki...

Thanks

Jrawke commented 8 years ago

If the API is missing, I'd be willing to add it. I imagine it should go in MumbleClient.js, by inserting member functions selfMute() and selfDeaf()

Rantanen commented 8 years ago

The API seems to be missing.

Despite the fact that I don't think you can self mute other people, I'd still say it should go to the User object. client.user.selfMute() isn't that much worse compared to client.selfMute() and it would help keeping the MumbleConnection interface cleaner.

The implementation should be simple enough. You need to construct a UserState protocol buffer message and send it to the server. The UserState has self_mute and self_deaf fields. Identify the user with the session field. I believe you can leave the user_id empty (as that might be null anyway if the connection isn't registered).

In the User context the protocol buffer messages are sent with this.client.connection.sendMessage(). You can check the joinChannel() for an example of its usage.

Think the methods should be named setSelfDeaf( boolean ) and setSelfMute( boolean ). The read-operations can still be done using user.selfDeaf field. I believe we'd also need a set( object ) method for setting multiple flags at the same time, ie:

client.user.set({ selfDeaf: true, selfMute: true });  // "User was muted and deafened"

Otherwise the mumble server would probably end up reporting "User X is deafened" "User X is muted" instead of "User X is muted and deafened".

Rantanen commented 8 years ago

Oh. And given the case of the set method, I'm now convinced that it should go to the User object and not the MumbleClient. Otherwise we'd need the set on the client or then we'd need to bypass it (in this case) with: setSelfMute, setSelfDeaf, setSelfMuteAndDeaf which is a recipe for disaster in the long run if we get more of these flags that affect only the current user. :)

Jrawke commented 8 years ago

Thanks for the quick and informative response. I'd like to add this functionality (you can assign me to this issue if you'd like). I'll try to do it over the weekend, you'll get a pull request when I get around to it

tjhorner commented 8 years ago

boop. check 2e3a13b96b65d8ec1593a50fdaf98252bad9f243

Jrawke commented 8 years ago

Less work for me :)

tjhorner commented 8 years ago

ye. I just did that in the browser in a minute or so lol