Skip to content

Commit

Permalink
Added gateway reconnect wait
Browse files Browse the repository at this point in the history
  • Loading branch information
Hackzzila committed Oct 19, 2016
1 parent 6a92697 commit 73e51be
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 10 deletions.
2 changes: 1 addition & 1 deletion lib/src/internal/_Constants.dart
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ class _OPCodes {
/// The client constants.
class _Constants {
static const String host = "https://discordapp.com/api/v6";
static const String version = "0.14.0";
static const String version = "0.14.1";

/// The gateway OP codes.
static const Map<String, int> opCodes = const <String, int>{
Expand Down
2 changes: 1 addition & 1 deletion lib/src/internal/_WS.dart
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ class _WS {
}

void connectShard(int index) {
this.client.shards.values.toList()[index]._connect();
this.client.shards.values.toList()[index]._connect(true, true);
if (index + 1 != this.client._options.shardIds.length)
new Timer(new Duration(seconds: 6), () => connectShard(index + 1));
}
Expand Down
10 changes: 6 additions & 4 deletions lib/src/objects/Guild.dart
Original file line number Diff line number Diff line change
Expand Up @@ -111,10 +111,12 @@ class Guild extends _BaseObj {

data['presences'].forEach((Map<String, dynamic> o) {
Member member = this.members[o['user']['id']];
member.status = o['status'];
if (o['game'] != null) {
member.game =
new Game._new(client, o['game'] as Map<String, dynamic>);
if (member != null) {
member.status = o['status'];
if (o['game'] != null) {
member.game =
new Game._new(client, o['game'] as Map<String, dynamic>);
}
}
});

Expand Down
8 changes: 5 additions & 3 deletions lib/src/objects/Shard.dart
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,12 @@ class Shard extends _BaseObj {
this.onError = new StreamController<Shard>.broadcast();
}

void _connect([bool resume = true]) {
void _connect([bool resume = true, bool init = false]) {
this.ready = false;
if (this._socket != null) {
this._socket.close();
if (this._socket != null) this._socket.close();
if (!init) {
new Timer(new Duration(seconds: 2), () => _connect(resume));
return;
}
new _WebSocket()
.connect('${this._ws.gateway}?v=6&encoding=json',
Expand Down
2 changes: 1 addition & 1 deletion pubspec.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
name: discord
version: 0.14.0
version: 0.14.1
description: A Discord library for Dart
author: Hackzzila <[email protected]>
homepage: https://hackzzila.github.io/Discord-Dart/
Expand Down

0 comments on commit 73e51be

Please sign in to comment.