Commit graph

91 commits

Author SHA1 Message Date
Erik McClure
bb4b96e26d Add heartbeat ACK response and error handling (#396)
* Add heartbeat ACK response and error handling

- Error when sending a heartbeat now triggers a reconnection
- Op7 now triggers a reconnection
- Session now tracks the last heartbeat ACK that was recieved. If the
last ACK is more than FailedHeartbeatAcks*heartbeatinterval in the past,
this is treated as a dead connection and a reconnection is forced.

* Address @iopred comments
2017-06-27 20:52:59 -07:00
Bruce
f2cad25dc9 Bump version to v0.17.0-dev 2017-05-15 16:12:45 +00:00
Bruce
0993a94b4e Bump version to 0.16.0 2017-05-15 15:02:49 +00:00
Bruce
2feb43f068 Merge branch 'master' into develop
Conflicts:
	README.md
	discord.go
2017-05-15 14:59:20 +00:00
Bruce
5e2c93b4f1 Added warning to New/Login functions fixes #342 2017-05-03 21:47:57 +00:00
Michael Köppl
d8f81e54bb Fix typo
It is called 'Semantic Versioning'
2017-04-29 23:21:10 +02:00
LEGOlord208
65f0cb9f73 Arise error when user has 2FA (#359)
* Arise error when user has 2FA

* Fixed error message

* Removed ticket
2017-04-18 21:35:17 -07:00
jonas747
2d50fc197f Fix racey heartbeat sequence (#303)
* Fix racey heartbeat sequence

* Change all sequence fields to int64
2016-12-28 11:59:02 -08:00
jonas747
edc3213ffb Reuse http client, and export it (#301) 2016-12-25 16:23:11 -08:00
Bruce Marriner
9e777a083b Linting. 2016-12-11 12:45:34 -06:00
Chris Rhodes
8b24e88bc5 Bump version to 0.16.0-dev 2016-12-10 06:47:49 -08:00
Chris Rhodes
5835676872 Bump version to 0.15.0 2016-12-10 06:47:14 -08:00
Chris Rhodes
36601253a4 Remove use of reflect.
This introduces gogenerate'ed EventHandlers from the files in events.go

This also adds support for AddHandlerOnce.
2016-12-03 23:31:07 -08:00
Chris Rhodes
315ae45231 Set GuildID on all members in discordgo land not in state. 2016-11-29 20:23:10 -08:00
Chris Rhodes
03343b41fd Update discord.go 2016-11-23 17:18:37 -08:00
Chris Rhodes
c352d7016c Clean up ordering of internal handlers. (#285) 2016-11-12 11:50:06 -08:00
jonas747
56b19073d3 Ratelimits (#273)
* Added ratelimiter

Handles the new ratelimit headers
 - X-RateLimit-Remaining
 - X-RateLimit-Reset
 - X-RateLimit-Global

* Pad only reset time with a second

* Moved ratelimiter out of internal package

* Change for loop, move global ratelimit check inside sleep check

* Moved ratelimiter locking to getBucket

* Added global bucket

* Changed how bucket id's are done

Now each request function will need to specify the bucket id if the
endpoint contains minor variables

* Allow empty bucketID in request

* Remove some uneeded Endpoint* function calls

* Added test for global ratelimits

* Fixed a silly little mistake causing incorrect ratelimits

* Update test comments, Fixed treating a endpoint as 2 in ratelimiting

* Use date header from discord instead of relying on sys time sync

* Update all REST functions to use RequestWithBucketID

* Embed mutex into bucket

* Added webhook and reaction buckets
2016-11-04 08:07:22 -07:00
Chris Rhodes
2e2e02fc11 Support a very light state in all cases to support b1nzy's upcoming PR (#260)
Support a very light state in all cases to support b1nzy's upcoming PR
2016-09-27 22:09:44 -07:00
Chris Rhodes
8bd3f75441 Merge pull request #227 from jonas747/retry
Retry on 502's
2016-09-27 21:19:25 -07:00
jonas747
ebb910f3ac Set default MaxRestRetries to 3 2016-09-27 18:25:40 +02:00
Bruce Marriner
43778dc54b Bump version to 0.14.0-dev 2016-07-19 07:44:38 -05:00
Bruce Marriner
11fa9dc906 Bump Version to 0.13.0 2016-07-18 17:12:48 -05:00
Bruce Marriner
9dc51d1c49 Only Shard when ShardCount > 1
Also cleaned up identify sending so there's now a function that handles
it instead of duplicate code.  Renamed handshake* structs to identify*
structs to make naming match up.
2016-06-14 13:45:38 -05:00
andrei
835a23a89d Implement guild sharding 2016-06-13 15:34:40 -07:00
Bruce Marriner
7ed2a289bc Fix possible mutex deadlock in handle()
Also added some logging.
2016-05-28 13:51:17 -05:00
Bruce Marriner
a9da8a5daf Cleanup, Logging, Finished Resumed code. 2016-04-30 21:40:13 -05:00
Bruce Marriner
f6de2b2c98 gateway, voice, & logging improvements
We now store teh sessionID of the gateway connection for later use. We
are now caching the gateway url and will use it until unable to connect
to that gateway.  We're not longer smashing the VoiceConnections map
during reconnects which was causing Voice problems. Slight change to
log output format.
2016-04-28 21:15:32 -05:00
Bruce Marriner
33f2fa8d81 Bump version to v0.13.0-alpha 2016-04-12 12:35:34 -05:00
Bruce Marriner
12b010078c Bump version to v0.12.0 2016-04-12 12:28:19 -05:00
Bruce Marriner
1a672823a2 Lint and Cleanup 2016-04-11 18:54:19 -05:00
Chris Rhodes
45e01b20c9 Fix ordering of the OnReady event and Session being updated. 2016-04-01 18:06:20 -07:00
Bruce Marriner
a40bf8952c Removed onEvent handler
With the recent change to the OnEvent event now always executing
insted of only on error we don't want this printing out every
single event.  A different way to handle unknown events will be
added in the wsapi.go code.
2016-03-21 17:54:04 -05:00
Bruce Marriner
cd065fa61a Revert "Removed onEvent handler"
This reverts commit 974ed749e1.

Deleted the wrong function...
2016-03-21 17:53:15 -05:00
Bruce Marriner
974ed749e1 Removed onEvent handler
With the recent change to the OnEvent event now always executing
insted of only on error we don't want this printing out every
single event.  A different way to handle unknown events will be
added in the wsapi.go code.
2016-03-21 17:47:22 -05:00
Chris Rhodes
584b06aae5 Support VoiceSpeakingUpdates on VoiceConnection. 2016-03-18 10:50:25 -07:00
Bruce Marriner
44d4667463 Bump to v0.12.0-alpha 2016-02-20 20:59:40 -06:00
Bruce Marriner
cadf36c775 Bump to v0.11.0 2016-02-20 20:53:56 -06:00
Chris Rhodes
457b03f66e Fix deadlock because I'm dumb. 2016-02-19 23:00:41 -08:00
Chris Rhodes
c291988335 Bring back the Lock as it's technically correct. 2016-02-19 22:32:15 -08:00
Chris Rhodes
79247272ff Handler updates, no backwards incompatible API changes.
AddHandler now returns a func that can remove the handler.
The handlers map is now guarded by its own mutex.
Moved eventMap to events.go for readability.
Improved documentation.
2016-02-19 22:28:21 -08:00
Chris Rhodes
32f8c03270 Fix a Lock instead of RLock in initialize. 2016-02-19 11:25:46 -08:00
Chris Rhodes
d22b7ffc90 Clean up mutexes around s.handlers so they exist only in discord.go 2016-02-17 23:17:31 -08:00
Bruce Marriner
aebfb09719 Baby Linting. 2016-02-15 21:50:41 -06:00
Chris Rhodes
b083ce00c7 Un-expose handlers. Clean up Session struct. 2016-02-14 21:58:29 -08:00
Chris Rhodes
88335b6f54 Small performance improvement. Added tests. 2016-02-14 19:01:45 -08:00
Chris Rhodes
6fa99712ef Finish converting large switch statement into a map of functions. 2016-02-14 18:48:37 -08:00
Chris Rhodes
8ffaa85b0b Thread safety and more events. 2016-02-14 13:41:56 -08:00
Chris Rhodes
fb6ae92555 Add basic support for mapped event handlers. 2016-02-14 13:17:20 -08:00
Bruce Marriner
f917d83f6e Linting. 2016-01-27 23:39:56 -06:00
Bruce Marriner
9a63e50e22 Bump dev to v0.11.0-alpha 2016-01-27 13:31:14 -06:00