Browse Source

feature: Remove /users/@me call for socket and rework sharded client a bit (#1860)

* Remove /users/@me call for socket and rework sharded client a bit

* Remove override for login
tags/3.0.0
Paulo GitHub 4 years ago
parent
commit
384ad85c64
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 4 additions and 15 deletions
  1. +1
    -1
      src/Discord.Net.WebSocket/BaseSocketClient.cs
  2. +3
    -9
      src/Discord.Net.WebSocket/DiscordShardedClient.cs
  3. +0
    -5
      src/Discord.Net.WebSocket/DiscordSocketClient.cs

+ 1
- 1
src/Discord.Net.WebSocket/BaseSocketClient.cs View File

@@ -47,7 +47,7 @@ namespace Discord.WebSocket
/// <summary>
/// Gets the current logged-in user.
/// </summary>
public new SocketSelfUser CurrentUser { get => base.CurrentUser as SocketSelfUser; protected set => base.CurrentUser = value; }
public virtual new SocketSelfUser CurrentUser { get => base.CurrentUser as SocketSelfUser; protected set => base.CurrentUser = value; }
/// <summary>
/// Gets a collection of guilds that the user is currently in.
/// </summary>


+ 3
- 9
src/Discord.Net.WebSocket/DiscordShardedClient.cs View File

@@ -40,7 +40,9 @@ namespace Discord.WebSocket
/// <summary>
/// Provides access to a REST-only client with a shared state from this client.
/// </summary>
public override DiscordSocketRestClient Rest => _shards[0].Rest;
public override DiscordSocketRestClient Rest => _shards?[0].Rest;

public override SocketSelfUser CurrentUser { get => _shards?.FirstOrDefault(x => x.CurrentUser != null)?.CurrentUser; protected set => throw new InvalidOperationException(); }

/// <summary> Creates a new REST/WebSocket Discord client. </summary>
public DiscordShardedClient() : this(null, new DiscordSocketConfig()) { }
@@ -330,14 +332,6 @@ namespace Discord.WebSocket
}
return Task.Delay(0);
};
if (isPrimary)
{
client.Ready += () =>
{
CurrentUser = client.CurrentUser;
return Task.Delay(0);
};
}

client.Connected += () => _shardConnectedEvent.InvokeAsync(client);
client.Disconnected += (exception) => _shardDisconnectedEvent.InvokeAsync(exception, client);


+ 0
- 5
src/Discord.Net.WebSocket/DiscordSocketClient.cs View File

@@ -193,11 +193,6 @@ namespace Discord.WebSocket
base.Dispose(disposing);
}

/// <inheritdoc />
internal override async Task OnLoginAsync(TokenType tokenType, string token)
{
await Rest.OnLoginAsync(tokenType, token);
}
/// <inheritdoc />
internal override async Task OnLogoutAsync()
{


Loading…
Cancel
Save