Use a better method for detecting if a voice socket is needed.
This commit is contained in:
@@ -52,7 +52,7 @@ namespace Discord
|
||||
|
||||
/// <summary> Initializes a new instance of the DiscordClient class. </summary>
|
||||
public DiscordClient(DiscordClientConfig config = null)
|
||||
: base(config, enableVoice: config.VoiceMode != DiscordVoiceMode.Disabled && !config.EnableVoiceMultiserver)
|
||||
: base(config)
|
||||
{
|
||||
_rand = new Random();
|
||||
_api = new DiscordAPIClient(_config.LogLevel, _config.UserAgent, _config.APITimeout);
|
||||
@@ -740,7 +740,7 @@ namespace Discord
|
||||
config.EnableVoiceMultiserver = false;
|
||||
config.VoiceOnly = true;
|
||||
config.VoiceClientId = unchecked(++_nextVoiceClientId);
|
||||
return new DiscordSimpleClient(config, true, serverId);
|
||||
return new DiscordSimpleClient(config, serverId);
|
||||
});
|
||||
client.LogMessage += (s, e) => RaiseOnLog(e.Severity, e.Source, $"(#{client.Config.VoiceClientId}) {e.Message}");
|
||||
await client.Connect(_gateway, _token).ConfigureAwait(false);
|
||||
|
||||
@@ -27,6 +27,9 @@ namespace Discord
|
||||
public bool AckMessages { get { return _ackMessages; } set { SetValue(ref _ackMessages, value); } }
|
||||
private bool _ackMessages = false;
|
||||
|
||||
//Internal
|
||||
internal override bool EnableVoice => base.EnableVoice && !EnableVoiceMultiserver;
|
||||
|
||||
public new DiscordClientConfig Clone()
|
||||
{
|
||||
var config = this.MemberwiseClone() as DiscordClientConfig;
|
||||
|
||||
@@ -51,14 +51,11 @@ namespace Discord
|
||||
|
||||
/// <summary> Initializes a new instance of the DiscordClient class. </summary>
|
||||
public DiscordSimpleClient(DiscordSimpleClientConfig config = null)
|
||||
: this(config, enableVoice: config.VoiceMode != DiscordVoiceMode.Disabled) { }
|
||||
internal DiscordSimpleClient(DiscordSimpleClientConfig config = null, bool enableVoice = false, string voiceServerId = null)
|
||||
{
|
||||
_config = config ?? new DiscordSimpleClientConfig();
|
||||
_config.Lock();
|
||||
|
||||
_enableVoice = enableVoice;
|
||||
_voiceServerId = voiceServerId;
|
||||
_enableVoice = _config.EnableVoice;
|
||||
|
||||
_state = (int)DiscordClientState.Disconnected;
|
||||
_cancelToken = new CancellationToken(true);
|
||||
@@ -69,6 +66,11 @@ namespace Discord
|
||||
if (_enableVoice)
|
||||
_voiceSocket = CreateVoiceSocket();
|
||||
}
|
||||
internal DiscordSimpleClient(DiscordSimpleClientConfig config = null, string voiceServerId = null)
|
||||
: this(config)
|
||||
{
|
||||
_voiceServerId = voiceServerId;
|
||||
}
|
||||
|
||||
internal virtual DataWebSocket CreateDataSocket()
|
||||
{
|
||||
|
||||
@@ -56,6 +56,7 @@ namespace Discord
|
||||
private bool _voiceOnly;
|
||||
internal uint VoiceClientId { get { return _voiceClientId; } set { SetValue(ref _voiceClientId, value); } }
|
||||
private uint _voiceClientId;
|
||||
internal virtual bool EnableVoice => _voiceMode != DiscordVoiceMode.Disabled;
|
||||
|
||||
internal string UserAgent
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user