Added logging to child voice clients
This commit is contained in:
@@ -23,6 +23,7 @@ namespace Discord
|
|||||||
private readonly ConcurrentQueue<Message> _pendingMessages;
|
private readonly ConcurrentQueue<Message> _pendingMessages;
|
||||||
private readonly ConcurrentDictionary<string, DiscordSimpleClient> _voiceClients;
|
private readonly ConcurrentDictionary<string, DiscordSimpleClient> _voiceClients;
|
||||||
private bool _sentInitialLog;
|
private bool _sentInitialLog;
|
||||||
|
private uint _nextVoiceClientId;
|
||||||
|
|
||||||
/// <summary> Returns the current logged-in user. </summary>
|
/// <summary> Returns the current logged-in user. </summary>
|
||||||
public User CurrentUser => _currentUser;
|
public User CurrentUser => _currentUser;
|
||||||
@@ -713,10 +714,13 @@ namespace Discord
|
|||||||
var client = _voiceClients.GetOrAdd(serverId, _ =>
|
var client = _voiceClients.GetOrAdd(serverId, _ =>
|
||||||
{
|
{
|
||||||
var config = _config.Clone();
|
var config = _config.Clone();
|
||||||
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.EnableVoiceMultiserver = false;
|
config.EnableVoiceMultiserver = false;
|
||||||
|
config.VoiceOnly = true;
|
||||||
|
config.VoiceClientId = unchecked(++_nextVoiceClientId);
|
||||||
return new DiscordSimpleClient(config, 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);
|
await client.Connect(_gateway, _token).ConfigureAwait(false);
|
||||||
return client;
|
return client;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -48,9 +48,6 @@ namespace Discord
|
|||||||
/// <summary> (Experimental) Enables the voice websocket and UDP client. This option requires the libsodium .dll or .so be in the local lib/ folder. </summary>
|
/// <summary> (Experimental) Enables the voice websocket and UDP client. This option requires the libsodium .dll or .so be in the local lib/ folder. </summary>
|
||||||
public bool EnableVoiceEncryption { get { return _enableVoiceEncryption; } set { SetValue(ref _enableVoiceEncryption, value); } }
|
public bool EnableVoiceEncryption { get { return _enableVoiceEncryption; } set { SetValue(ref _enableVoiceEncryption, value); } }
|
||||||
private bool _enableVoiceEncryption = true;
|
private bool _enableVoiceEncryption = true;
|
||||||
/// <summary> (Experimental) Enables the client to be simultaneously connected to multiple channels at once (Discord still limits you to one channel per server). </summary>
|
|
||||||
public bool EnableVoiceMultiserver { get { return _enableVoiceMultiserver; } set { SetValue(ref _enableVoiceMultiserver, value); } }
|
|
||||||
private bool _enableVoiceMultiserver = false;
|
|
||||||
#else
|
#else
|
||||||
internal DiscordVoiceMode VoiceMode => DiscordVoiceMode.Disabled;
|
internal DiscordVoiceMode VoiceMode => DiscordVoiceMode.Disabled;
|
||||||
internal bool EnableVoiceEncryption => false;
|
internal bool EnableVoiceEncryption => false;
|
||||||
@@ -63,6 +60,14 @@ namespace Discord
|
|||||||
public bool TrackActivity { get { return _trackActivity; } set { SetValue(ref _trackActivity, value); } }
|
public bool TrackActivity { get { return _trackActivity; } set { SetValue(ref _trackActivity, value); } }
|
||||||
private bool _trackActivity = true;
|
private bool _trackActivity = true;
|
||||||
|
|
||||||
|
/// <summary> (Experimental) Enables the client to be simultaneously connected to multiple channels at once (Discord still limits you to one channel per server). </summary>
|
||||||
|
public bool EnableVoiceMultiserver { get { return _enableVoiceMultiserver; } set { SetValue(ref _enableVoiceMultiserver, value); } }
|
||||||
|
private bool _enableVoiceMultiserver = false;
|
||||||
|
internal bool VoiceOnly { get { return _voiceOnly; } set { SetValue(ref _voiceOnly, value); } }
|
||||||
|
private bool _voiceOnly;
|
||||||
|
internal uint VoiceClientId { get { return _voiceClientId; } set { SetValue(ref _voiceClientId, value); } }
|
||||||
|
private uint _voiceClientId;
|
||||||
|
|
||||||
//Lock
|
//Lock
|
||||||
private bool _isLocked;
|
private bool _isLocked;
|
||||||
internal void Lock() { _isLocked = true; }
|
internal void Lock() { _isLocked = true; }
|
||||||
|
|||||||
@@ -86,12 +86,16 @@ namespace Discord
|
|||||||
if (e.WasUnexpected)
|
if (e.WasUnexpected)
|
||||||
await socket.Reconnect(_token);
|
await socket.Reconnect(_token);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
if (!_config.VoiceOnly)
|
||||||
|
{
|
||||||
socket.LogMessage += (s, e) => RaiseOnLog(e.Severity, LogMessageSource.DataWebSocket, e.Message);
|
socket.LogMessage += (s, e) => RaiseOnLog(e.Severity, LogMessageSource.DataWebSocket, e.Message);
|
||||||
if (_config.LogLevel >= LogMessageSeverity.Info)
|
if (_config.LogLevel >= LogMessageSeverity.Info)
|
||||||
{
|
{
|
||||||
socket.Connected += (s, e) => RaiseOnLog(LogMessageSeverity.Info, LogMessageSource.DataWebSocket, "Connected");
|
socket.Connected += (s, e) => RaiseOnLog(LogMessageSeverity.Info, LogMessageSource.DataWebSocket, "Connected");
|
||||||
socket.Disconnected += (s, e) => RaiseOnLog(LogMessageSeverity.Info, LogMessageSource.DataWebSocket, "Disconnected");
|
socket.Disconnected += (s, e) => RaiseOnLog(LogMessageSeverity.Info, LogMessageSource.DataWebSocket, "Disconnected");
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
socket.ReceivedEvent += (s, e) => OnReceivedEvent(e);
|
socket.ReceivedEvent += (s, e) => OnReceivedEvent(e);
|
||||||
return socket;
|
return socket;
|
||||||
|
|||||||
Reference in New Issue
Block a user