Renamed OpCode enums
This commit is contained in:
@@ -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
|
||||||
|
|||||||
@@ -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,
|
||||||
@@ -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,
|
||||||
Reference in New Issue
Block a user