45 Commits

Author SHA1 Message Date
Rapptz
e445fa9335 Wait 5 seconds before attempting to RESUME during INVALIDATE_SESSION. 2017-04-22 21:34:56 -04:00
Rapptz
3cfebc4605 Timeout when doing initial connection. 2017-04-22 02:18:35 -04:00
Rapptz
1fc08bc5a2 Remove unused imports. 2017-04-18 04:22:35 -04:00
Rapptz
3b1b26ffb1 Re-implement voice sending.
This is a complete redesign of the old voice code.

A list of major changes is as follows:

* The voice websocket will now automatically reconnect with
  exponential back-off just like the regular Client does.
* Removal of the stream player concept.
* Audio now gracefully pauses and resumes when a disconnect is found.
* Introduce a discord.AudioSource concept to abstract streams
* Flatten previous stream player functionality with the
  VoiceClient, e.g. player.stop() is now voice_client.stop()
* With the above re-coupling this means you no longer have to
  store players anywhere.
* The after function now requires a single parameter, the error,
  if any existed. This will typically be None.

A lot of this design is experimental.
2017-04-18 03:49:48 -04:00
Rapptz
ac90159c72 Improve logging in more places.
This shows the Shard ID in more places, along with a gateway trace and
session ID. Also helps show the RESUME/IDENTIFY/RESUMED/READY flow a
bit more instead of it looking like the connection has zombied out.
2017-04-12 19:43:47 -04:00
Rapptz
1b3234ab64 Add info logging for close codes we cannot handle. 2017-02-24 17:23:46 -05:00
Rapptz
a6b180b5ad Don't RESUME when given sharding related close codes. 2017-02-15 17:58:57 -05:00
Rapptz
ced064d08c Add missing continue statement in gateway futures. 2017-02-08 20:30:09 -05:00
Rapptz
ecab8399ff Handle HEARTBEAT_ACK 2017-02-08 07:23:09 -05:00
Rapptz
dc486980f8 Rewrite RESUME logic to be more in line with what is requested.
Apparently we should always try to RESUME first and if we get
INVALIDATE_SESSION then we should IDENTIFY instead. This is the
preferred way to do RESUMEs.
2017-02-08 04:37:16 -05:00
Rapptz
b876133e87 Add compatibility shim for asyncio.Future creation.
Should provide better support for uvloop.
2017-01-25 21:38:50 -05:00
Rapptz
ff9f5749e1 Update copyright year to 2017. 2017-01-20 23:19:19 -05:00
Rapptz
4bc6625739 Add AutoShardedClient.change_presence. 2017-01-08 01:51:10 -05:00
Rapptz
b5bed9ef33 Change the way shards are launched in AutoShardedClient. 2017-01-08 01:31:46 -05:00
Rapptz
20041ea756 Implement AutoShardedClient for transparent sharding.
This allows people to run their >2,500 guild bot in a single process
without the headaches of IPC/RPC or much difficulty.
2017-01-07 23:19:39 -05:00
Rapptz
98b981848d Move message creation to a factory method inside ConnectionState. 2017-01-03 09:52:10 -05:00
Rapptz
79a49f9145 Absolute import some circular dependencies to appease Python 3.4. 2017-01-03 09:52:02 -05:00
Rapptz
d1d54a468a Rename Server to Guild everywhere. 2017-01-03 09:51:54 -05:00
Rapptz
6306fc08db Discard null sequences in the gateway.
This was forbidding the Discord gateway from allowing us to RESUME
properly, causing an over-abundance of READY being called.
2016-12-16 18:29:29 -05:00
khazhyk
98d8c855d8 Fix typo in change_presence validation message 2016-10-15 15:54:50 -07:00
Rapptz
7272190e2d Add support for "Do Not Disturb" and "Invisible" statuses.
This deprecates Client.change_status in favour of the newer and more
correct Client.change_presence.
2016-09-26 19:55:42 -04:00
Rapptz
fc1155c160 Remove unused endpoints.py file. 2016-09-25 21:54:38 -04:00
Rapptz
a23e51f6c4 Fix gateway code to work with websockets 3.2. 2016-08-25 17:09:34 -04:00
Rapptz
0b6e74ebec Ensure that keep alive threads are closed when a websocket closes.
The library worked with the assumption that whenever the recv call for
the websocket would lead to a closure, the close method would be called
to signal closure and as a result our close method would be called.

This assumption turned out to be false as the websockets library would
instead call an internal function named close_connection instead. So to
solve our problem we need to override this function instead of close.
2016-08-21 11:45:41 -04:00
Rapptz
0c95edab8c Handle receiving HEARTBEAT opcode. 2016-07-30 13:03:22 -04:00
Rapptz
ddd3fd0a3d Begin working on gateway v6 changes.
The first batch of changes are related to channel types and group
direct messages. Support these first so READY begins parsing.
2016-07-13 00:10:16 -04:00
Rapptz
e600abbbab Ignore HEARTBEAT_ACK for now to disable the noisy logging. 2016-06-27 21:32:43 -04:00
cookie
abf9be5f7d Guild Sharding support 2016-06-26 14:47:16 -04:00
Rapptz
8b3617111a Support for v5 Gateway. 2016-06-22 05:00:08 -04:00
Rapptz
92fe4daa86 Attempt resume when we receive a 1001. 2016-06-16 19:13:13 -04:00
Rapptz
aecf0daf33 Fix sed error involved in creation of voice websocket. 2016-06-12 21:16:57 -04:00
Rapptz
dbd3147059 Support more close codes for RESUME. 2016-06-12 20:48:23 -04:00
Rapptz
1fba1b06fa Rewrite HTTP handling significantly.
This should have a more uniform approach to rate limit handling. Instead
of queueing every request, wait until we receive a 429 and then block
the requesting bucket until we're done being rate limited. This should
reduce the number of 429s done by the API significantly (about 66% avg).

This also consistently checks for 502 retries across all requests.
2016-06-12 20:33:09 -04:00
Jake
41a2b5ed73 Actually read from the voice websocket & fix heartbeat.
This change makes it so that the buffer doesn't fill and the voice server drops the socket.

Also, use correct interval for voice websocket heartbeat.
2016-06-05 21:18:36 -07:00
Rapptz
f6fa1e837a Actually use v4 gateway and fixes thanks to Jake. 2016-06-02 07:32:35 -04:00
Rapptz
8638ff4414 Update voice client main ws references when reconnecting. 2016-06-01 05:20:22 -04:00
Rapptz
e0a91df32b Add RESUME support. 2016-06-01 05:13:15 -04:00
Rapptz
e66b2dce88 Rename threading internal variable conflict. 2016-05-13 20:24:45 -04:00
Rapptz
0c8d5ee863 Force encoding of text retrieval functions to use utf-8.
Closes #207
2016-05-10 19:52:34 -04:00
Rapptz
3feba5d1bb Add Game.type and Game.url attributes to change streaming status. 2016-05-06 16:38:22 -04:00
Rapptz
701720a0f8 Add a TimeoutError if VoiceClient.connect fails. 2016-05-06 13:30:44 -04:00
Rapptz
570ccbf753 Suppress ConnectionClosed on sending in the main websocket. 2016-05-06 13:19:41 -04:00
Rapptz
d9c780b8a8 Working multi-server voice support. 2016-05-01 20:54:13 -04:00
Rapptz
c1b5a52823 Refactor voice websocket into gateway.py 2016-04-27 18:36:24 -04:00
Rapptz
1c623ccf11 Begin working on gateway v4 support.
Bump websockets requirement to v3.1

Should be squashed...
2016-04-27 18:36:13 -04:00