Skip to content

Commit 73b6587

Browse files
committed
fix: event name incompabilities
This commit fixes incompabilities due to internal Node.js behaviors while emitting an event called "end".
1 parent ed60efb commit 73b6587

File tree

5 files changed

+10
-5
lines changed

5 files changed

+10
-5
lines changed

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@ client.ws.on('VOICE_SERVER_UPDATE', (data) => {
5555
endpoint: buffer.endpoint
5656
})
5757

58+
stream.on('end', () => stream.emit('finishBuffering')) /* Allow it to end once it finds null */
5859
connection.connect(() => connection.play(stream))
5960
}
6061
})

docs/Connection/play.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,4 +41,8 @@ Nothing.
4141

4242
- Instead of requiring the stream to end with 0, it now requires the stream to emit the `end` event when it finished buffering.
4343

44+
### 2.0.2
45+
46+
- Due to incompabilities with Node.js with `end` event, now it was renamed to `finishBuffering`.
47+
4448
</details>

index.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,7 @@ class Connection extends EventEmitter {
123123

124124
this.ws = new WebSocket(`wss://${this.voiceServer.endpoint}/?v=4`, {
125125
headers: {
126-
'User-Agent': 'DiscordBot (https://github.com/PerformanC/voice, 2.0.1)'
126+
'User-Agent': 'DiscordBot (https://github.com/PerformanC/voice, 2.0.2)'
127127
}
128128
})
129129

@@ -417,7 +417,7 @@ class Connection extends EventEmitter {
417417
if (chunk) this.sendAudioChunk(packetBuffer, chunk)
418418
}, OPUS_FRAME_DURATION)
419419

420-
this.audioStream.once('end', () => shouldStop = true)
420+
this.audioStream.once('finishBuffering', () => shouldStop = true)
421421
}
422422

423423
_destroyConnection(code, reason) {

package-lock.json

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@performanc/voice",
3-
"version": "2.0.1",
3+
"version": "2.0.2",
44
"description": "Performant Discord voice API client for ES6 Node.js",
55
"main": "index.js",
66
"type": "module",

0 commit comments

Comments
 (0)