@@ -149,9 +149,9 @@ namespace Discord.Audio | |||||
{ | { | ||||
int id = unchecked(++_nextClientId); | int id = unchecked(++_nextClientId); | ||||
var logger = Client.Log().CreateLogger($"Voice #{id}"); | var logger = Client.Log().CreateLogger($"Voice #{id}"); | ||||
DataWebSocket dataSocket = null; | |||||
GatewayWebSocket dataSocket = null; | |||||
var voiceSocket = new VoiceWebSocket(Client.Config, _config, logger); | var voiceSocket = new VoiceWebSocket(Client.Config, _config, logger); | ||||
var voiceClient = new DiscordAudioClient(this, id, logger, dataSocket, voiceSocket); | |||||
var voiceClient = new DiscordAudioClient(this, id, logger, gatewaySocket, voiceSocket); | |||||
voiceClient.SetServerId(server.Id); | voiceClient.SetServerId(server.Id); | ||||
voiceSocket.OnPacket += (s, e) => | voiceSocket.OnPacket += (s, e) => | ||||
@@ -166,7 +166,7 @@ namespace Discord.Audio | |||||
return voiceClient; | return voiceClient; | ||||
}); | }); | ||||
//await client.Connect(dataSocket.Host, _client.Token).ConfigureAwait(false); | |||||
//await client.Connect(gatewaySocket.Host, _client.Token).ConfigureAwait(false); | |||||
return Task.FromResult(client); | return Task.FromResult(client); | ||||
} | } | ||||
@@ -10,19 +10,19 @@ namespace Discord.Audio | |||||
public int Id => _id; | public int Id => _id; | ||||
private readonly AudioService _service; | private readonly AudioService _service; | ||||
private readonly DataWebSocket _dataSocket; | |||||
private readonly GatewayWebSocket _gatewaySocket; | |||||
private readonly VoiceWebSocket _voiceSocket; | private readonly VoiceWebSocket _voiceSocket; | ||||
private readonly Logger _logger; | private readonly Logger _logger; | ||||
public long? ServerId => _voiceSocket.ServerId; | public long? ServerId => _voiceSocket.ServerId; | ||||
public long? ChannelId => _voiceSocket.ChannelId; | public long? ChannelId => _voiceSocket.ChannelId; | ||||
public DiscordAudioClient(AudioService service, int id, Logger logger, DataWebSocket dataSocket, VoiceWebSocket voiceSocket) | |||||
public DiscordAudioClient(AudioService service, int id, Logger logger, GatewayWebSocket gatewaySocket, VoiceWebSocket voiceSocket) | |||||
{ | { | ||||
_service = service; | _service = service; | ||||
_id = id; | _id = id; | ||||
_logger = logger; | _logger = logger; | ||||
_dataSocket = dataSocket; | |||||
_gatewaySocket = gatewaySocket; | |||||
_voiceSocket = voiceSocket; | _voiceSocket = voiceSocket; | ||||
/*_voiceSocket.Connected += (s, e) => RaiseVoiceConnected(); | /*_voiceSocket.Connected += (s, e) => RaiseVoiceConnected(); | ||||
@@ -30,7 +30,7 @@ namespace Discord.Audio | |||||
{ | { | ||||
_voiceSocket.CurrentServerId; | _voiceSocket.CurrentServerId; | ||||
if (voiceServerId != null) | if (voiceServerId != null) | ||||
_dataSocket.SendLeaveVoice(voiceServerId.Value); | |||||
_gatewaySocket.SendLeaveVoice(voiceServerId.Value); | |||||
await _voiceSocket.Disconnect().ConfigureAwait(false); | await _voiceSocket.Disconnect().ConfigureAwait(false); | ||||
RaiseVoiceDisconnected(socket.CurrentServerId.Value, e); | RaiseVoiceDisconnected(socket.CurrentServerId.Value, e); | ||||
if (e.WasUnexpected) | if (e.WasUnexpected) | ||||
@@ -59,7 +59,7 @@ namespace Discord.Audio | |||||
_voiceSocket.ParentCancelToken = _cancelToken; | _voiceSocket.ParentCancelToken = _cancelToken; | ||||
};*/ | };*/ | ||||
_dataSocket.ReceivedEvent += async (s, e) => | |||||
_gatewaySocket.ReceivedEvent += async (s, e) => | |||||
{ | { | ||||
try | try | ||||
{ | { | ||||
@@ -74,7 +74,7 @@ namespace Discord.Audio | |||||
var client = _service.Client; | var client = _service.Client; | ||||
string token = e.Payload.Value<string>("token"); | string token = e.Payload.Value<string>("token"); | ||||
_voiceSocket.Host = "wss://" + e.Payload.Value<string>("endpoint").Split(':')[0]; | _voiceSocket.Host = "wss://" + e.Payload.Value<string>("endpoint").Split(':')[0]; | ||||
await _voiceSocket.Login(client.CurrentUser.Id, _dataSocket.SessionId, token, client.CancelToken).ConfigureAwait(false); | |||||
await _voiceSocket.Login(client.CurrentUser.Id, _gatewaySocket.SessionId, token, client.CancelToken).ConfigureAwait(false); | |||||
} | } | ||||
} | } | ||||
break; | break; | ||||
@@ -82,7 +82,7 @@ namespace Discord.Audio | |||||
} | } | ||||
catch (Exception ex) | catch (Exception ex) | ||||
{ | { | ||||
_dataSocket.Logger.Log(LogSeverity.Error, $"Error handling {e.Type} event", ex); | |||||
_gatewaySocket.Logger.Log(LogSeverity.Error, $"Error handling {e.Type} event", ex); | |||||
} | } | ||||
}; | }; | ||||
} | } | ||||
@@ -106,7 +106,7 @@ namespace Discord.Audio | |||||
await _voiceSocket.Disconnect().ConfigureAwait(false); | await _voiceSocket.Disconnect().ConfigureAwait(false); | ||||
_voiceSocket.ChannelId = channel.Id; | _voiceSocket.ChannelId = channel.Id; | ||||
_dataSocket.SendJoinVoice(channel.Server.Id, channel.Id); | |||||
_gatewaySocket.SendJoinVoice(channel.Server.Id, channel.Id); | |||||
await _voiceSocket.WaitForConnection(_service.Config.ConnectionTimeout).ConfigureAwait(false); | await _voiceSocket.WaitForConnection(_service.Config.ConnectionTimeout).ConfigureAwait(false); | ||||
} | } | ||||
@@ -12,7 +12,7 @@ namespace Discord.API | |||||
[JsonProperty("url")] | [JsonProperty("url")] | ||||
public string Url; | public string Url; | ||||
} | } | ||||
//Login | //Login | ||||
public sealed class LoginRequest | public sealed class LoginRequest | ||||
{ | { | ||||
@@ -1,10 +0,0 @@ | |||||
//Ignore unused/unassigned variable warnings | |||||
#pragma warning disable CS0649 | |||||
#pragma warning disable CS0169 | |||||
namespace Discord.API | |||||
{ | |||||
//Events | |||||
internal sealed class BanAddEvent : MemberReference { } | |||||
internal sealed class BanRemoveEvent : MemberReference { } | |||||
} |
@@ -46,4 +46,6 @@ namespace Discord.API | |||||
//Events | //Events | ||||
internal sealed class UserUpdateEvent : UserInfo { } | internal sealed class UserUpdateEvent : UserInfo { } | ||||
internal sealed class BanAddEvent : MemberReference { } | |||||
internal sealed class BanRemoveEvent : MemberReference { } | |||||
} | } |
@@ -82,8 +82,8 @@ namespace Discord | |||||
private readonly DiscordAPIClient _api; | private readonly DiscordAPIClient _api; | ||||
/// <summary> Returns the internal websocket object. </summary> | /// <summary> Returns the internal websocket object. </summary> | ||||
public DataWebSocket WebSocket => _webSocket; | |||||
private readonly DataWebSocket _webSocket; | |||||
public GatewayWebSocket WebSocket => _webSocket; | |||||
private readonly GatewayWebSocket _webSocket; | |||||
public string GatewayUrl => _gateway; | public string GatewayUrl => _gateway; | ||||
private string _gateway; | private string _gateway; | ||||
@@ -257,9 +257,9 @@ namespace Discord | |||||
} | } | ||||
} | } | ||||
private DataWebSocket CreateWebSocket() | |||||
private GatewayWebSocket CreateWebSocket() | |||||
{ | { | ||||
var socket = new DataWebSocket(_config, _log.CreateLogger("WebSocket")); | |||||
var socket = new GatewayWebSocket(_config, _log.CreateLogger("WebSocket")); | |||||
var settings = new JsonSerializerSettings(); | var settings = new JsonSerializerSettings(); | ||||
socket.Connected += (s, e) => | socket.Connected += (s, e) => | ||||
{ | { | ||||
@@ -6,7 +6,7 @@ using System.Threading.Tasks; | |||||
namespace Discord.Net.WebSockets | namespace Discord.Net.WebSockets | ||||
{ | { | ||||
public partial class DataWebSocket : WebSocket | |||||
public partial class GatewayWebSocket : WebSocket | |||||
{ | { | ||||
internal enum OpCodes : byte | internal enum OpCodes : byte | ||||
{ | { | ||||
@@ -26,7 +26,7 @@ namespace Discord.Net.WebSockets | |||||
public string SessionId => _sessionId; | public string SessionId => _sessionId; | ||||
private string _sessionId; | private string _sessionId; | ||||
public DataWebSocket(DiscordConfig config, Logger logger) | |||||
public GatewayWebSocket(DiscordConfig config, Logger logger) | |||||
: base(config, logger) | : base(config, logger) | ||||
{ | { | ||||
} | } |
@@ -14,7 +14,7 @@ namespace Discord.Net.WebSockets | |||||
} | } | ||||
} | } | ||||
public partial class DataWebSocket | |||||
public partial class GatewayWebSocket | |||||
{ | { | ||||
public event EventHandler<WebSocketEventEventArgs> ReceivedEvent; | public event EventHandler<WebSocketEventEventArgs> ReceivedEvent; | ||||
private void RaiseReceivedEvent(string type, JToken payload) | private void RaiseReceivedEvent(string type, JToken payload) |