| @@ -169,17 +169,17 @@ | |||||
| <Compile Include="..\Discord.Net\DiscordClientConfig.cs"> | <Compile Include="..\Discord.Net\DiscordClientConfig.cs"> | ||||
| <Link>DiscordClientConfig.cs</Link> | <Link>DiscordClientConfig.cs</Link> | ||||
| </Compile> | </Compile> | ||||
| <Compile Include="..\Discord.Net\DiscordWebSocketClient.cs"> | |||||
| <Link>DiscordWebSocketClient.cs</Link> | |||||
| <Compile Include="..\Discord.Net\DiscordWSClient.cs"> | |||||
| <Link>DiscordWSClient.cs</Link> | |||||
| </Compile> | </Compile> | ||||
| <Compile Include="..\Discord.Net\DiscordWebSocketClient.Events.cs"> | |||||
| <Link>DiscordWebSocketClient.Events.cs</Link> | |||||
| <Compile Include="..\Discord.Net\DiscordWSClient.Events.cs"> | |||||
| <Link>DiscordWSClient.Events.cs</Link> | |||||
| </Compile> | </Compile> | ||||
| <Compile Include="..\Discord.Net\DiscordWebSocketClient.Voice.cs"> | |||||
| <Link>DiscordWebSocketClient.Voice.cs</Link> | |||||
| <Compile Include="..\Discord.Net\DiscordWSClient.Voice.cs"> | |||||
| <Link>DiscordWSClient.Voice.cs</Link> | |||||
| </Compile> | </Compile> | ||||
| <Compile Include="..\Discord.Net\DiscordWebSocketClientConfig.cs"> | |||||
| <Link>DiscordWebSocketClientConfig.cs</Link> | |||||
| <Compile Include="..\Discord.Net\DiscordWSClientConfig.cs"> | |||||
| <Link>DiscordWSClientConfig.cs</Link> | |||||
| </Compile> | </Compile> | ||||
| <Compile Include="..\Discord.Net\Helpers\EpochTime.cs"> | <Compile Include="..\Discord.Net\Helpers\EpochTime.cs"> | ||||
| <Link>Helpers\EpochTime.cs</Link> | <Link>Helpers\EpochTime.cs</Link> | ||||
| @@ -14,13 +14,13 @@ using System.Threading.Tasks; | |||||
| namespace Discord | namespace Discord | ||||
| { | { | ||||
| /// <summary> Provides a connection to the DiscordApp service. </summary> | /// <summary> Provides a connection to the DiscordApp service. </summary> | ||||
| public partial class DiscordClient : DiscordWebSocketClient | |||||
| public partial class DiscordClient : DiscordWSClient | |||||
| { | { | ||||
| protected readonly DiscordAPIClient _api; | protected readonly DiscordAPIClient _api; | ||||
| private readonly Random _rand; | private readonly Random _rand; | ||||
| private readonly JsonSerializer _serializer; | private readonly JsonSerializer _serializer; | ||||
| private readonly ConcurrentQueue<Message> _pendingMessages; | private readonly ConcurrentQueue<Message> _pendingMessages; | ||||
| private readonly ConcurrentDictionary<string, DiscordWebSocketClient> _voiceClients; | |||||
| private readonly ConcurrentDictionary<string, DiscordWSClient> _voiceClients; | |||||
| private bool _sentInitialLog; | private bool _sentInitialLog; | ||||
| private uint _nextVoiceClientId; | private uint _nextVoiceClientId; | ||||
| private string _status; | private string _status; | ||||
| @@ -61,7 +61,7 @@ namespace Discord | |||||
| if (Config.UseMessageQueue) | if (Config.UseMessageQueue) | ||||
| _pendingMessages = new ConcurrentQueue<Message>(); | _pendingMessages = new ConcurrentQueue<Message>(); | ||||
| if (Config.EnableVoiceMultiserver) | if (Config.EnableVoiceMultiserver) | ||||
| _voiceClients = new ConcurrentDictionary<string, DiscordWebSocketClient>(); | |||||
| _voiceClients = new ConcurrentDictionary<string, DiscordWSClient>(); | |||||
| object cacheLock = new object(); | object cacheLock = new object(); | ||||
| _channels = new Channels(this, cacheLock); | _channels = new Channels(this, cacheLock); | ||||
| @@ -749,7 +749,7 @@ namespace Discord | |||||
| return null; | return null; | ||||
| } | } | ||||
| DiscordWebSocketClient client; | |||||
| DiscordWSClient client; | |||||
| if (_voiceClients.TryGetValue(serverId, out client)) | if (_voiceClients.TryGetValue(serverId, out client)) | ||||
| return client; | return client; | ||||
| else | else | ||||
| @@ -769,7 +769,7 @@ namespace Discord | |||||
| config.LogLevel = _config.LogLevel;// (LogMessageSeverity)Math.Min((int)_config.LogLevel, (int)LogMessageSeverity.Warning); | config.LogLevel = _config.LogLevel;// (LogMessageSeverity)Math.Min((int)_config.LogLevel, (int)LogMessageSeverity.Warning); | ||||
| config.VoiceOnly = true; | config.VoiceOnly = true; | ||||
| config.VoiceClientId = unchecked(++_nextVoiceClientId); | config.VoiceClientId = unchecked(++_nextVoiceClientId); | ||||
| return new DiscordWebSocketClient(config, serverId); | |||||
| return new DiscordWSClient(config, serverId); | |||||
| }); | }); | ||||
| client.LogMessage += (s, e) => RaiseOnLog(e.Severity, e.Source, $"(#{client.Config.VoiceClientId}) {e.Message}"); | client.LogMessage += (s, e) => RaiseOnLog(e.Severity, e.Source, $"(#{client.Config.VoiceClientId}) {e.Message}"); | ||||
| await client.Connect(_gateway, _token).ConfigureAwait(false); | await client.Connect(_gateway, _token).ConfigureAwait(false); | ||||
| @@ -800,7 +800,7 @@ namespace Discord | |||||
| if (Config.EnableVoiceMultiserver) | if (Config.EnableVoiceMultiserver) | ||||
| { | { | ||||
| DiscordWebSocketClient client; | |||||
| DiscordWSClient client; | |||||
| if (_voiceClients.TryRemove(serverId, out client)) | if (_voiceClients.TryRemove(serverId, out client)) | ||||
| await client.Disconnect(); | await client.Disconnect(); | ||||
| } | } | ||||
| @@ -1,6 +1,6 @@ | |||||
| namespace Discord | namespace Discord | ||||
| { | { | ||||
| public class DiscordClientConfig : DiscordWebSocketClientConfig | |||||
| public class DiscordClientConfig : DiscordWSClientConfig | |||||
| { | { | ||||
| /// <summary> Gets or sets the time (in milliseconds) to wait when the message queue is empty before checking again. </summary> | /// <summary> Gets or sets the time (in milliseconds) to wait when the message queue is empty before checking again. </summary> | ||||
| public int MessageQueueInterval { get { return _messageQueueInterval; } set { SetValue(ref _messageQueueInterval, value); } } | public int MessageQueueInterval { get { return _messageQueueInterval; } set { SetValue(ref _messageQueueInterval, value); } } | ||||
| @@ -73,7 +73,7 @@ namespace Discord | |||||
| } | } | ||||
| } | } | ||||
| public partial class DiscordWebSocketClient | |||||
| public partial class DiscordWSClient | |||||
| { | { | ||||
| public event EventHandler Connected; | public event EventHandler Connected; | ||||
| private void RaiseConnected() | private void RaiseConnected() | ||||
| @@ -4,7 +4,7 @@ using System.Threading.Tasks; | |||||
| namespace Discord | namespace Discord | ||||
| { | { | ||||
| public partial class DiscordWebSocketClient : IDiscordVoiceClient | |||||
| public partial class DiscordWSClient : IDiscordVoiceClient | |||||
| { | { | ||||
| IDiscordVoiceBuffer IDiscordVoiceClient.OutputBuffer => _voiceSocket.OutputBuffer; | IDiscordVoiceBuffer IDiscordVoiceClient.OutputBuffer => _voiceSocket.OutputBuffer; | ||||
| @@ -17,8 +17,8 @@ namespace Discord | |||||
| Disconnecting | Disconnecting | ||||
| } | } | ||||
| /// <summary> Provides a barebones connection to the Discord service </summary> | |||||
| public partial class DiscordWebSocketClient | |||||
| /// <summary> Provides a minimalistic websocket connection to the Discord service. </summary> | |||||
| public partial class DiscordWSClient | |||||
| { | { | ||||
| internal readonly DataWebSocket _dataSocket; | internal readonly DataWebSocket _dataSocket; | ||||
| internal readonly VoiceWebSocket _voiceSocket; | internal readonly VoiceWebSocket _voiceSocket; | ||||
| @@ -33,8 +33,8 @@ namespace Discord | |||||
| private bool _wasDisconnectUnexpected; | private bool _wasDisconnectUnexpected; | ||||
| /// <summary> Returns the configuration object used to make this client. Note that this object cannot be edited directly - to change the configuration of this client, use the DiscordClient(DiscordClientConfig config) constructor. </summary> | /// <summary> Returns the configuration object used to make this client. Note that this object cannot be edited directly - to change the configuration of this client, use the DiscordClient(DiscordClientConfig config) constructor. </summary> | ||||
| public DiscordWebSocketClientConfig Config => _config; | |||||
| protected readonly DiscordWebSocketClientConfig _config; | |||||
| public DiscordWSClientConfig Config => _config; | |||||
| protected readonly DiscordWSClientConfig _config; | |||||
| /// <summary> Returns the id of the current logged-in user. </summary> | /// <summary> Returns the id of the current logged-in user. </summary> | ||||
| public string CurrentUserId => _currentUserId; | public string CurrentUserId => _currentUserId; | ||||
| @@ -51,9 +51,9 @@ namespace Discord | |||||
| private CancellationToken _cancelToken; | private CancellationToken _cancelToken; | ||||
| /// <summary> Initializes a new instance of the DiscordClient class. </summary> | /// <summary> Initializes a new instance of the DiscordClient class. </summary> | ||||
| public DiscordWebSocketClient(DiscordWebSocketClientConfig config = null) | |||||
| public DiscordWSClient(DiscordWSClientConfig config = null) | |||||
| { | { | ||||
| _config = config ?? new DiscordWebSocketClientConfig(); | |||||
| _config = config ?? new DiscordWSClientConfig(); | |||||
| _config.Lock(); | _config.Lock(); | ||||
| _enableVoice = _config.EnableVoice; | _enableVoice = _config.EnableVoice; | ||||
| @@ -67,7 +67,7 @@ namespace Discord | |||||
| if (_enableVoice) | if (_enableVoice) | ||||
| _voiceSocket = CreateVoiceSocket(); | _voiceSocket = CreateVoiceSocket(); | ||||
| } | } | ||||
| internal DiscordWebSocketClient(DiscordWebSocketClientConfig config = null, string voiceServerId = null) | |||||
| internal DiscordWSClient(DiscordWSClientConfig config = null, string voiceServerId = null) | |||||
| : this(config) | : this(config) | ||||
| { | { | ||||
| _voiceServerId = voiceServerId; | _voiceServerId = voiceServerId; | ||||
| @@ -12,7 +12,7 @@ namespace Discord | |||||
| Both = Outgoing | Incoming | Both = Outgoing | Incoming | ||||
| } | } | ||||
| public class DiscordWebSocketClientConfig : DiscordAPIClientConfig | |||||
| public class DiscordWSClientConfig : DiscordAPIClientConfig | |||||
| { | { | ||||
| /// <summary> Max time in milliseconds to wait for DiscordClient to connect and initialize. </summary> | /// <summary> Max time in milliseconds to wait for DiscordClient to connect and initialize. </summary> | ||||
| public int ConnectionTimeout { get { return _connectionTimeout; } set { SetValue(ref _connectionTimeout, value); } } | public int ConnectionTimeout { get { return _connectionTimeout; } set { SetValue(ref _connectionTimeout, value); } } | ||||
| @@ -47,9 +47,9 @@ namespace Discord | |||||
| internal virtual bool EnableVoice => _voiceMode != DiscordVoiceMode.Disabled; | internal virtual bool EnableVoice => _voiceMode != DiscordVoiceMode.Disabled; | ||||
| public new DiscordWebSocketClientConfig Clone() | |||||
| public new DiscordWSClientConfig Clone() | |||||
| { | { | ||||
| var config = MemberwiseClone() as DiscordWebSocketClientConfig; | |||||
| var config = MemberwiseClone() as DiscordWSClientConfig; | |||||
| config._isLocked = false; | config._isLocked = false; | ||||
| return config; | return config; | ||||
| } | } | ||||
| @@ -13,7 +13,7 @@ namespace Discord.Net.WebSockets | |||||
| public string SessionId => _sessionId; | public string SessionId => _sessionId; | ||||
| private string _sessionId; | private string _sessionId; | ||||
| public DataWebSocket(DiscordWebSocketClient client) | |||||
| public DataWebSocket(DiscordWSClient client) | |||||
| : base(client) | : base(client) | ||||
| { | { | ||||
| } | } | ||||
| @@ -46,7 +46,7 @@ namespace Discord.Net.WebSockets | |||||
| public string CurrentChannelId => _channelId; | public string CurrentChannelId => _channelId; | ||||
| public VoiceBuffer OutputBuffer => _sendBuffer; | public VoiceBuffer OutputBuffer => _sendBuffer; | ||||
| public VoiceWebSocket(DiscordWebSocketClient client) | |||||
| public VoiceWebSocket(DiscordWSClient client) | |||||
| : base(client) | : base(client) | ||||
| { | { | ||||
| _rand = new Random(); | _rand = new Random(); | ||||
| @@ -19,7 +19,7 @@ namespace Discord.Net.WebSockets | |||||
| internal abstract partial class WebSocket | internal abstract partial class WebSocket | ||||
| { | { | ||||
| protected readonly IWebSocketEngine _engine; | protected readonly IWebSocketEngine _engine; | ||||
| protected readonly DiscordWebSocketClient _client; | |||||
| protected readonly DiscordWSClient _client; | |||||
| protected readonly LogMessageSeverity _logLevel; | protected readonly LogMessageSeverity _logLevel; | ||||
| protected readonly ManualResetEventSlim _connectedEvent; | protected readonly ManualResetEventSlim _connectedEvent; | ||||
| @@ -41,7 +41,7 @@ namespace Discord.Net.WebSockets | |||||
| public WebSocketState State => (WebSocketState)_state; | public WebSocketState State => (WebSocketState)_state; | ||||
| protected int _state; | protected int _state; | ||||
| public WebSocket(DiscordWebSocketClient client) | |||||
| public WebSocket(DiscordWSClient client) | |||||
| { | { | ||||
| _client = client; | _client = client; | ||||
| _logLevel = client.Config.LogLevel; | _logLevel = client.Config.LogLevel; | ||||
| @@ -10,7 +10,7 @@ namespace Discord.Net.WebSockets | |||||
| { | { | ||||
| internal class WebSocketSharpEngine : IWebSocketEngine | internal class WebSocketSharpEngine : IWebSocketEngine | ||||
| { | { | ||||
| private readonly DiscordWebSocketClientConfig _config; | |||||
| private readonly DiscordWSClientConfig _config; | |||||
| private readonly ConcurrentQueue<string> _sendQueue; | private readonly ConcurrentQueue<string> _sendQueue; | ||||
| private readonly WebSocket _parent; | private readonly WebSocket _parent; | ||||
| private WSSharpNWebSocket _webSocket; | private WSSharpNWebSocket _webSocket; | ||||
| @@ -22,7 +22,7 @@ namespace Discord.Net.WebSockets | |||||
| ProcessMessage(this, new WebSocketMessageEventArgs(msg)); | ProcessMessage(this, new WebSocketMessageEventArgs(msg)); | ||||
| } | } | ||||
| internal WebSocketSharpEngine(WebSocket parent, DiscordWebSocketClientConfig config) | |||||
| internal WebSocketSharpEngine(WebSocket parent, DiscordWSClientConfig config) | |||||
| { | { | ||||
| _parent = parent; | _parent = parent; | ||||
| _config = config; | _config = config; | ||||