Browse Source

Renamed OpCode enums

tags/1.0-rc
RogueException 9 years ago
parent
commit
d55e0309a0
3 changed files with 10 additions and 12 deletions
  1. +7
    -9
      src/Discord.Net/API/DiscordAPIClient.cs
  2. +1
    -1
      src/Discord.Net/API/Gateway/GatewayOpCode.cs
  3. +2
    -2
      src/Discord.Net/API/Voice/VoiceOpCode.cs

+ 7
- 9
src/Discord.Net/API/DiscordAPIClient.cs View File

@@ -27,7 +27,7 @@ namespace Discord.API
{ {
public event Func<string, string, double, Task> SentRequest; public event Func<string, string, double, Task> SentRequest;
public event Func<int, Task> SentGatewayMessage; public event Func<int, Task> SentGatewayMessage;
public event Func<GatewayOpCodes, string, JToken, Task> ReceivedGatewayEvent;
public event Func<GatewayOpCode, string, JToken, Task> ReceivedGatewayEvent;


private readonly RequestQueue _requestQueue; private readonly RequestQueue _requestQueue;
private readonly JsonSerializer _serializer; private readonly JsonSerializer _serializer;
@@ -66,14 +66,14 @@ namespace Discord.API
using (var reader = new StreamReader(decompressed)) using (var reader = new StreamReader(decompressed))
{ {
var msg = JsonConvert.DeserializeObject<WebSocketMessage>(reader.ReadToEnd()); var msg = JsonConvert.DeserializeObject<WebSocketMessage>(reader.ReadToEnd());
await ReceivedGatewayEvent.Raise((GatewayOpCodes)msg.Operation, msg.Type, msg.Payload as JToken).ConfigureAwait(false);
await ReceivedGatewayEvent.Raise((GatewayOpCode)msg.Operation, msg.Type, msg.Payload as JToken).ConfigureAwait(false);
} }
} }
}; };
_gatewayClient.TextMessage += async text => _gatewayClient.TextMessage += async text =>
{ {
var msg = JsonConvert.DeserializeObject<WebSocketMessage>(text); var msg = JsonConvert.DeserializeObject<WebSocketMessage>(text);
await ReceivedGatewayEvent.Raise((GatewayOpCodes)msg.Operation, msg.Type, msg.Payload as JToken).ConfigureAwait(false);
await ReceivedGatewayEvent.Raise((GatewayOpCode)msg.Operation, msg.Type, msg.Payload as JToken).ConfigureAwait(false);
}; };
} }


@@ -198,8 +198,6 @@ namespace Discord.API
var url = $"{gatewayResponse.Url}?v={DiscordConfig.GatewayAPIVersion}&encoding={DiscordConfig.GatewayEncoding}"; var url = $"{gatewayResponse.Url}?v={DiscordConfig.GatewayAPIVersion}&encoding={DiscordConfig.GatewayEncoding}";
await _gatewayClient.Connect(url).ConfigureAwait(false); await _gatewayClient.Connect(url).ConfigureAwait(false);


await SendIdentify().ConfigureAwait(false);

ConnectionState = ConnectionState.Connected; ConnectionState = ConnectionState.Connected;
} }
catch (Exception) catch (Exception)
@@ -321,13 +319,13 @@ namespace Discord.API
return responseStream; return responseStream;
} }


public Task SendGateway(GatewayOpCodes opCode, object payload,
public Task SendGateway(GatewayOpCode opCode, object payload,
GlobalBucket bucket = GlobalBucket.GeneralGateway, RequestOptions options = null) GlobalBucket bucket = GlobalBucket.GeneralGateway, RequestOptions options = null)
=> SendGateway(opCode, payload, BucketGroup.Global, (int)bucket, 0, options); => SendGateway(opCode, payload, BucketGroup.Global, (int)bucket, 0, options);
public Task SendGateway(GatewayOpCodes opCode, object payload,
public Task SendGateway(GatewayOpCode opCode, object payload,
GuildBucket bucket, ulong guildId, RequestOptions options = null) GuildBucket bucket, ulong guildId, RequestOptions options = null)
=> SendGateway(opCode, payload, BucketGroup.Guild, (int)bucket, guildId, options); => SendGateway(opCode, payload, BucketGroup.Guild, (int)bucket, guildId, options);
private async Task SendGateway(GatewayOpCodes opCode, object payload,
private async Task SendGateway(GatewayOpCode opCode, object payload,
BucketGroup group, int bucketId, ulong guildId, RequestOptions options) BucketGroup group, int bucketId, ulong guildId, RequestOptions options)
{ {
//TODO: Add ETF //TODO: Add ETF
@@ -363,7 +361,7 @@ namespace Discord.API
LargeThreshold = largeThreshold, LargeThreshold = largeThreshold,
UseCompression = useCompression UseCompression = useCompression
}; };
await SendGateway(GatewayOpCodes.Identify, msg, options: options).ConfigureAwait(false);
await SendGateway(GatewayOpCode.Identify, msg, options: options).ConfigureAwait(false);
} }


//Channels //Channels


src/Discord.Net/API/Gateway/GatewayOpCodes.cs → src/Discord.Net/API/Gateway/GatewayOpCode.cs View File

@@ -1,6 +1,6 @@
namespace Discord.API.Gateway namespace Discord.API.Gateway
{ {
public enum GatewayOpCodes : byte
public enum GatewayOpCode : byte
{ {
/// <summary> C←S - Used to send most events. </summary> /// <summary> C←S - Used to send most events. </summary>
Dispatch = 0, Dispatch = 0,

src/Discord.Net/API/Voice/VoiceOpCodes.cs → src/Discord.Net/API/Voice/VoiceOpCode.cs View File

@@ -1,6 +1,6 @@
namespace Discord.API.Gateway
namespace Discord.API.Voice
{ {
public enum VoiceOpCodes : byte
public enum VoiceOpCode : byte
{ {
/// <summary> C→S - Used to associate a connection with a token. </summary> /// <summary> C→S - Used to associate a connection with a token. </summary>
Identify = 0, Identify = 0,

Loading…
Cancel
Save