forked from abner/for-legacy-web
Merge pull request #131 from ryanalexander/new-voice-interface
This commit is contained in:
@@ -40,6 +40,8 @@ export default class VoiceClient extends EventEmitter<VoiceEvents> {
|
||||
sendTransport?: Transport;
|
||||
recvTransport?: Transport;
|
||||
|
||||
isDeaf?: boolean;
|
||||
|
||||
userId?: string;
|
||||
roomId?: string;
|
||||
participants: Map<string, VoiceUser>;
|
||||
@@ -54,6 +56,8 @@ export default class VoiceClient extends EventEmitter<VoiceEvents> {
|
||||
this.participants = new Map();
|
||||
this.consumers = new Map();
|
||||
|
||||
this.isDeaf = false;
|
||||
|
||||
this.signaling.on(
|
||||
"data",
|
||||
(json) => {
|
||||
|
||||
@@ -143,6 +143,33 @@ class VoiceStateReference {
|
||||
}
|
||||
}
|
||||
|
||||
isDeaf() {
|
||||
if(!this.client)
|
||||
return false;
|
||||
|
||||
return this.client.isDeaf;
|
||||
}
|
||||
|
||||
async startDeafen() {
|
||||
if(!this.client)
|
||||
return console.log("No client object"); // ! TODO: let the user know
|
||||
|
||||
this.client.isDeaf = true;
|
||||
|
||||
this.client?.consumers.forEach(consumer => {
|
||||
consumer.audio?.pause();
|
||||
})
|
||||
}
|
||||
async stopDeafen() {
|
||||
if(!this.client)
|
||||
return console.log("No client object"); // ! TODO: let the user know
|
||||
|
||||
this.client.isDeaf = false;
|
||||
this.client?.consumers.forEach(consumer => {
|
||||
consumer.audio?.resume();
|
||||
})
|
||||
}
|
||||
|
||||
async startProducing(type: ProduceType) {
|
||||
switch (type) {
|
||||
case "audio": {
|
||||
|
||||
Reference in New Issue
Block a user