Renamed DiscordSimpleClient -> DiscordWebSocketClient, moved DiscordAPIClient back into root namespace.

This commit is contained in:
RogueException
2015-10-18 18:02:47 -03:00
parent a2480ebaeb
commit 23e8ec8a0c
11 changed files with 33 additions and 32 deletions

View File

@@ -148,6 +148,9 @@
<Compile Include="..\Discord.Net\Collections\Users.cs">
<Link>Collections\Users.cs</Link>
</Compile>
<Compile Include="..\Discord.Net\DiscordAPIClient.cs">
<Link>DiscordAPIClient.cs</Link>
</Compile>
<Compile Include="..\Discord.Net\DiscordClient.API.cs">
<Link>DiscordClient.API.cs</Link>
</Compile>
@@ -163,17 +166,17 @@
<Compile Include="..\Discord.Net\DiscordClientConfig.cs">
<Link>DiscordClientConfig.cs</Link>
</Compile>
<Compile Include="..\Discord.Net\DiscordSimpleClient.cs">
<Link>DiscordSimpleClient.cs</Link>
<Compile Include="..\Discord.Net\DiscordWebSocketClient.cs">
<Link>DiscordWebSocketClient.cs</Link>
</Compile>
<Compile Include="..\Discord.Net\DiscordSimpleClient.Events.cs">
<Link>DiscordSimpleClient.Events.cs</Link>
<Compile Include="..\Discord.Net\DiscordWebSocketClient.Events.cs">
<Link>DiscordWebSocketClient.Events.cs</Link>
</Compile>
<Compile Include="..\Discord.Net\DiscordSimpleClient.Voice.cs">
<Link>DiscordSimpleClient.Voice.cs</Link>
<Compile Include="..\Discord.Net\DiscordWebSocketClient.Voice.cs">
<Link>DiscordWebSocketClient.Voice.cs</Link>
</Compile>
<Compile Include="..\Discord.Net\DiscordSimpleClientConfig.cs">
<Link>DiscordSimpleClientConfig.cs</Link>
<Compile Include="..\Discord.Net\DiscordWebSocketClientConfig.cs">
<Link>DiscordWebSocketClientConfig.cs</Link>
</Compile>
<Compile Include="..\Discord.Net\Helpers\EpochTime.cs">
<Link>Helpers\EpochTime.cs</Link>
@@ -244,9 +247,6 @@
<Compile Include="..\Discord.Net\Net\DataWebSockets.Events.cs">
<Link>Net\DataWebSockets.Events.cs</Link>
</Compile>
<Compile Include="..\Discord.Net\Net\DiscordAPIClient.cs">
<Link>Net\DiscordAPIClient.cs</Link>
</Compile>
<Compile Include="..\Discord.Net\Net\HttpException.cs">
<Link>Net\HttpException.cs</Link>
</Compile>

View File

@@ -1,11 +1,12 @@
using Discord.API;
using Discord.Net;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading;
using System.Threading.Tasks;
namespace Discord.Net
namespace Discord
{
/// <summary> A lightweight wrapper around the Discord API. </summary>
public class DiscordAPIClient

View File

@@ -12,13 +12,13 @@ using System.Threading.Tasks;
namespace Discord
{
/// <summary> Provides a connection to the DiscordApp service. </summary>
public partial class DiscordClient : DiscordSimpleClient
public partial class DiscordClient : DiscordWebSocketClient
{
protected readonly DiscordAPIClient _api;
private readonly Random _rand;
private readonly JsonSerializer _serializer;
private readonly ConcurrentQueue<Message> _pendingMessages;
private readonly ConcurrentDictionary<string, DiscordSimpleClient> _voiceClients;
private readonly ConcurrentDictionary<string, DiscordWebSocketClient> _voiceClients;
private bool _sentInitialLog;
private uint _nextVoiceClientId;
private string _status;
@@ -59,7 +59,7 @@ namespace Discord
if (Config.UseMessageQueue)
_pendingMessages = new ConcurrentQueue<Message>();
if (Config.EnableVoiceMultiserver)
_voiceClients = new ConcurrentDictionary<string, DiscordSimpleClient>();
_voiceClients = new ConcurrentDictionary<string, DiscordWebSocketClient>();
object cacheLock = new object();
_channels = new Channels(this, cacheLock);
@@ -747,7 +747,7 @@ namespace Discord
return null;
}
DiscordSimpleClient client;
DiscordWebSocketClient client;
if (_voiceClients.TryGetValue(serverId, out client))
return client;
else
@@ -768,7 +768,7 @@ namespace Discord
config.EnableVoiceMultiserver = false;
config.VoiceOnly = true;
config.VoiceClientId = unchecked(++_nextVoiceClientId);
return new DiscordSimpleClient(config, serverId);
return new DiscordWebSocketClient(config, serverId);
});
client.LogMessage += (s, e) => RaiseOnLog(e.Severity, e.Source, $"(#{client.Config.VoiceClientId}) {e.Message}");
await client.Connect(_gateway, _token).ConfigureAwait(false);
@@ -799,7 +799,7 @@ namespace Discord
if (Config.EnableVoiceMultiserver)
{
DiscordSimpleClient client;
DiscordWebSocketClient client;
if (_voiceClients.TryRemove(serverId, out client))
await client.Disconnect();
}

View File

@@ -1,6 +1,6 @@
namespace Discord
{
public class DiscordClientConfig : DiscordSimpleClientConfig
public class DiscordClientConfig : DiscordWebSocketClientConfig
{
/// <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); } }

View File

@@ -73,7 +73,7 @@ namespace Discord
}
}
public partial class DiscordSimpleClient
public partial class DiscordWebSocketClient
{
public event EventHandler Connected;
private void RaiseConnected()

View File

@@ -23,7 +23,7 @@ namespace Discord
Task WaitVoice();
}
public partial class DiscordSimpleClient : IDiscordVoiceClient
public partial class DiscordWebSocketClient : IDiscordVoiceClient
{
IDiscordVoiceBuffer IDiscordVoiceClient.OutputBuffer => _voiceSocket.OutputBuffer;

View File

@@ -17,7 +17,7 @@ namespace Discord
}
/// <summary> Provides a barebones connection to the Discord service </summary>
public partial class DiscordSimpleClient
public partial class DiscordWebSocketClient
{
internal readonly DataWebSocket _dataSocket;
internal readonly VoiceWebSocket _voiceSocket;
@@ -32,8 +32,8 @@ namespace Discord
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>
public DiscordSimpleClientConfig Config => _config;
protected readonly DiscordSimpleClientConfig _config;
public DiscordWebSocketClientConfig Config => _config;
protected readonly DiscordWebSocketClientConfig _config;
/// <summary> Returns the id of the current logged-in user. </summary>
public string CurrentUserId => _currentUserId;
@@ -50,9 +50,9 @@ namespace Discord
private CancellationToken _cancelToken;
/// <summary> Initializes a new instance of the DiscordClient class. </summary>
public DiscordSimpleClient(DiscordSimpleClientConfig config = null)
public DiscordWebSocketClient(DiscordWebSocketClientConfig config = null)
{
_config = config ?? new DiscordSimpleClientConfig();
_config = config ?? new DiscordWebSocketClientConfig();
_config.Lock();
_enableVoice = _config.EnableVoice;
@@ -66,7 +66,7 @@ namespace Discord
if (_enableVoice)
_voiceSocket = CreateVoiceSocket();
}
internal DiscordSimpleClient(DiscordSimpleClientConfig config = null, string voiceServerId = null)
internal DiscordWebSocketClient(DiscordWebSocketClientConfig config = null, string voiceServerId = null)
: this(config)
{
_voiceServerId = voiceServerId;

View File

@@ -12,7 +12,7 @@ namespace Discord
Both = Outgoing | Incoming
}
public class DiscordSimpleClientConfig
public class DiscordWebSocketClientConfig
{
/// <summary> Specifies the minimum log level severity that will be sent to the LogMessage event. Warning: setting this to debug will really hurt performance but should help investigate any internal issues. </summary>
public LogMessageSeverity LogLevel { get { return _logLevel; } set { SetValue(ref _logLevel, value); } }

View File

@@ -13,7 +13,7 @@ namespace Discord.Net
public string SessionId => _sessionId;
private string _sessionId;
public DataWebSocket(DiscordSimpleClient client)
public DataWebSocket(DiscordWebSocketClient client)
: base(client)
{
}

View File

@@ -45,7 +45,7 @@ namespace Discord.Net
public string CurrentChannelId => _channelId;
public VoiceBuffer OutputBuffer => _sendBuffer;
public VoiceWebSocket(DiscordSimpleClient client)
public VoiceWebSocket(DiscordWebSocketClient client)
: base(client)
{
_rand = new Random();

View File

@@ -34,7 +34,7 @@ namespace Discord.Net
internal abstract partial class WebSocket
{
protected readonly IWebSocketEngine _engine;
protected readonly DiscordSimpleClient _client;
protected readonly DiscordWebSocketClient _client;
protected readonly LogMessageSeverity _logLevel;
protected readonly ManualResetEventSlim _connectedEvent;
@@ -56,7 +56,7 @@ namespace Discord.Net
public WebSocketState State => (WebSocketState)_state;
protected int _state;
public WebSocket(DiscordSimpleClient client)
public WebSocket(DiscordWebSocketClient client)
{
_client = client;
_logLevel = client.Config.LogLevel;