1
0
Fork 0
mirror of https://github.com/diamondburned/arikawa.git synced 2024-11-16 03:44:26 +00:00
Commit graph

49 commits

Author SHA1 Message Date
diamondburned 3b5a4ed94d Voice: Add packet correction for RTCP per RFC3350 2021-02-22 12:33:12 -08:00
diamondburned c6d8c741e8 CI: Add perseverance test for Gateway 2020-12-31 23:48:29 -08:00
diamondburned f1f052180b Heart: Improve thread-safety and pace responsiveness
This commit consists of these smaller commits:

    Gateway: SessionID to be a method for thread safety

	This commit breaks the SessionID field of the Gateway struct to
	be thread-safe by wrapping its access with a read-write mutex.
	As this is a bug fix, it is reasonable of a breaking change

    Heart: Allow later binding of event channel

    Voice: Use the new Heart API

    Heart: Fixed data races

    Heart: Allow changing pace, thread-safe Heartbeat
2020-12-31 01:32:45 -08:00
diamondburned b8994ed0da Voice: Remove state-keeping of sessions
This commit gets rid of all the code that previously managed different
voice sessions in different guilds. This is because there is rarely ever
a need for this, and most bots that need this could do their own
keeping.

This change, although removes some features off of the package, adds a
lot of clarity on what to do exactly when it comes to connecting to a
voice channel.

In order to make the migration process a bit easier, an example has been
added which guides through using the voice.Session API.
2020-11-30 19:12:20 -08:00
diamondburned 6727f0e728 Voice: Fixed voice tests for new JoinChannel 2020-11-30 17:04:11 -08:00
diamondburned 4df72dc891 Voice: JoinChannel no longer takes in an extra GuildID 2020-11-30 16:58:28 -08:00
diamondburned 1463d6e675 Voice: Rename NewVoice... to New 2020-11-30 16:46:43 -08:00
diamondburned 0d427cab71 Voice: Allow New without intents 2020-11-30 16:42:26 -08:00
Tyler Stuyfzand 75d6be7a9d
Voice: Add receive capability (#174)
* Resolve issue with copied v1 struct

* Speaking event patches, support Client Connect/Disconnect events

* Remove extra debug in heart.go

* Initial voice packet reading

* Resolve unallocated slices, use a static slice/array for decryption, split version/type

* Use separate slice for recvOpus, check return of secretbox.Open, and use constant for header size

* Update missing reference to packetHeaderSize

* Resolve decryption issues, add ReadPacket to session

* Update documentation for recvBuf/recvOpus

* Update comment for recvPacket's array
2020-11-29 17:32:18 -08:00
diamondburned 8356a8a3f6 Voice: Omit deprecated function in tests 2020-11-18 16:18:15 -08:00
diamondburned 6bdac16c2a Voice: Allow custom frame parameters; removed StopSpeaking
This comimt adds a method into the UDP connection to control the
internal frequency ticker which controls the speed of playback. For more
information, refer to (*voice/udp.Connection).ResetFrequency().

StopSpeaking is removed because it no longer works with variable
parameters. The functionality of that method was also arguably useless,
as it only sends silent frames.
2020-11-17 14:43:00 -08:00
diamondburned f4750292eb Voice: Minor concurrency improvements
This commit adds multiple thread safe guards to do better the
concurrency promises. However, it also omits completely those guarantees
in certain places that don't make sense to call concurrently. This is
mostly documented.

This commit also adds a small piece of code to concurrently run things
with the race detector.
2020-11-17 12:15:05 -08:00
diamondburned 1b8af1513e Voice: UDP now thread unsafe for performance
This commit omits thread safe guarantees in the UDP voice connection.
This is done because the UDP connection should not be shared across
threads, so those guarantees are now omitted for performance.

Session will still guard a UDP connection around a read mutex, because
Session itself has thread safe guarantees. This may change in the
future.
2020-11-17 12:15:05 -08:00
Tyler Stuyfzand 38fe1fafd0 Voice: Add UserID to SpeakingData 2020-11-17 12:15:05 -08:00
Tyler 59539403b3 Voice: Implement Voice Gateway events
Speaking event patches and support Client Connect/Disconnect events.
2020-11-17 12:15:05 -08:00
diamondburned d1242fc39a Voice: Remove Session from repository before disconnecting
This commit introduces this change so that Voice can be called from
other threads without waiting for one Session to disconnect itself.
2020-11-17 11:01:34 -08:00
Tyler Stuyfzand de7d7f62a4
Voice: Add UserID to SpeakingData (#161) 2020-11-15 01:37:56 -08:00
diamondburned f85aac09be Voice: Added intent adders into constructor 2020-11-12 18:55:05 -08:00
mavolin 88258b51c2 replace usage of discordapp.com with discord.com in docs 2020-11-03 10:14:53 -08:00
diamondburned 16c1658163 {,Voice}Gateway: Refactored Closing
This commit refactors both wsutil, the normal Gateway and the Voice
Gateway to have better closing behavior, which should assume less and
cover edge cases completely.
2020-10-30 11:02:37 -07:00
diamondburned 9c1088bf7c Voice: Fixed test error caused by Gateway API changes 2020-10-29 13:27:32 -07:00
diamondburned 2afcd1bc87 Merge Gateway regression fixes from v1 2020-10-29 11:32:54 -07:00
diamondburned f88d4e4b1e Gateway: Fixed wsutil build fail regression 2020-10-29 11:32:30 -07:00
diamondburned 75df94d9f4 *: Migrated Go Modules to v2 2020-10-28 15:39:59 -07:00
diamondburned 6c332ac145 {Voice,}Gateway: Fixed various race conditions
This commit fixes race conditions in both package voice, package
voicegateway and package gateway.

Originally, several race conditions exist when both the user's and the
pacemaker's goroutines both want to do several things to the websocket
connection. For example, the user's goroutine could be writing, and the
pacemaker's goroutine could trigger a reconnection. This is racey.

This issue is partially fixed by removing the pacer loop from package
heart and combining the ticker into the event (pacemaker) loop itself.

Technically, a race condition could still be triggered with care, but
the API itself never guaranteed any of those. As events are handled
using an internal loop into a channel, a race condition will not be
triggered just by handling events and writing to the websocket.
2020-10-22 10:47:27 -07:00
diamondburned 3312c66515 Voice: Made EventLoop a valid struct value instead of nil pointer 2020-08-19 21:32:40 -07:00
diamondburned de61fd912d wsutil: Made PacemakerLoop valid as zero-value 2020-08-19 21:30:57 -07:00
Maximilian von Lindern 1585797b52 *: Linting and typo fixes (#134)
* Linting and typo fixes

* Linting and typo fixes

* revert comma fix
2020-07-29 16:58:33 -07:00
Maximilian von Lindern 908ef96089 Discord: Uint64 typed Snowflakes (#132)
* Use typed Snowflakes if possible

* Discord: make Snowflakes uint64

* Fix errors that emerged because of new typing
2020-07-29 16:58:33 -07:00
Maximilian von Lindern 32789bb6e2 *: Separate utils and internal (#129)
* Utils: move package utils/heart to internal/heart

* Utils: move package utils/moreatomic to internal/moreatomic

* Utils: move package utils/zlib to internal/zlib
2020-07-29 16:58:33 -07:00
Maximilian von Lindern 78c36f13cd Discord: Rename Snowflake and Timestamp Valid methods (#128)
* Discord: rename Snowflake.Valid() to IsValid()

* Discord: rename Timestamp.Valid() to IsValid()
2020-07-29 16:58:33 -07:00
Tadeo Kondrak d290b0d01c *: Add typed Snowflake IDs (#122)
This PR closes #120.
2020-07-29 16:58:33 -07:00
diamondburned 6717f8002c Gateway: Fixed autoreconnect misusing context 2020-07-15 16:39:40 -07:00
diamondburned edb8a46ef2 Gateway: Added intent helpers and more context API support 2020-07-11 12:50:32 -07:00
diamondburned (Forefront) 9da01cccb3 Voice: Fixed a potential Write() stalling bug 2020-05-20 15:05:50 -07:00
mavolin 41ce1f389e
make all error messages lowercase 2020-05-16 23:14:49 +02:00
Matthew Penner 3aa92c8f05 Only add the guild to SessionErrors if the error is not nil 2020-05-13 15:38:07 -06:00
Matthew Penner 60346f23bb Close voice connections when Close() is called 2020-05-13 14:43:00 -06:00
diamondburned (Forefront) 23b0abdfec Adopted several packages to use NullSnowflake and NullSeconds 2020-05-08 14:25:07 -07:00
diamondburned (Forefront) 51e88a47b2 Gateway/Voice: Improved the event loop, fixed race conditions 2020-04-25 00:13:07 -07:00
diamondburned (Forefront) cc153e1715 Voice: Updated package description 2020-04-24 20:29:14 -07:00
diamondburned (Forefront) f2d93fe2ba Voice: Updated README 2020-04-24 20:14:06 -07:00
diamondburned (Forefront) 3005c7b44a Voice: Separated UDP and WS into packages, added io.Writer API 2020-04-24 19:36:33 -07:00
diamondburned (Forefront) c0c17085ba Heart: Migrated Voice to PacemakerLoop 2020-04-23 20:52:18 -07:00
diamondburned (Forefront) 4cfde32531 Voice: Added an integration test 2020-04-23 20:52:12 -07:00
Matthew Penner 6a029e0c80 Improvements to the way voice waits for events 2020-04-21 16:37:22 -06:00
Matthew Penner 7b17afc8e9 Improvements to voice/README.md 2020-04-21 16:37:22 -06:00
Matthew Penner 1e5e0ac38a Update go.sum, add voice/README.md with basic information on how the voice package functions 2020-04-21 16:37:22 -06:00
Matthew Penner f429010ded Add janky voice support 2020-04-21 16:37:22 -06:00