discordjs / voice

Implementation of the Discord Voice API for discord.js and other JS/TS libraries
Apache License 2.0
327 stars 110 forks source link

feat!: keep alive mechanism to detect connectivity to Discord #89

Closed amishshah closed 3 years ago

amishshah commented 3 years ago

Please describe the changes this PR makes and why it should be merged:

Adds a keep alive mechanism to the UDP socket, that allows 60 seconds for Discord to echo keep alive messages back to the sender. If 60 seconds pass, the UDP socket emits an error warning that a connection between the client and Discord is likely unavailable, causing the voice connection to attempt to reconnect.

A breaking change because connection.ping is now of type { ws: ?number, udp: ?number } instead of just ?number.

Status and versioning classification:

codecov[bot] commented 3 years ago

Codecov Report

Merging #89 (ebf51dc) into main (0ce79d6) will increase coverage by 1.02%. The diff coverage is 71.42%.

Impacted file tree graph

@@            Coverage Diff             @@
##             main      #89      +/-   ##
==========================================
+ Coverage   55.41%   56.44%   +1.02%     
==========================================
  Files          15       15              
  Lines         637      675      +38     
  Branches      143      149       +6     
==========================================
+ Hits          353      381      +28     
- Misses        282      292      +10     
  Partials        2        2              
Impacted Files Coverage Δ
src/VoiceConnection.ts 78.57% <0.00%> (-0.71%) :arrow_down:
src/networking/Networking.ts 3.67% <0.00%> (-0.27%) :arrow_down:
src/networking/VoiceUDPSocket.ts 98.07% <96.77%> (+2.24%) :arrow_up:

Continue to review full report at Codecov.

Legend - Click here to learn more Δ = absolute <relative> (impact), ø = not affected, ? = missing data Powered by Codecov. Last update 0ce79d6...ebf51dc. Read the comment docs.