Added MessageQueue logging

This commit is contained in:
RogueException
2015-12-29 20:43:55 -04:00
parent ed20d55438
commit 225837f2e4
2 changed files with 8 additions and 3 deletions

View File

@@ -125,7 +125,7 @@ namespace Discord
GatewaySocket.ReceivedDispatch += (s, e) => OnReceivedEvent(e); GatewaySocket.ReceivedDispatch += (s, e) => OnReceivedEvent(e);
if (Config.UseMessageQueue) if (Config.UseMessageQueue)
MessageQueue = new MessageQueue(this); MessageQueue = new MessageQueue(this, Log.CreateLogger("MessageQueue"));
Connected += async (s, e) => Connected += async (s, e) =>
{ {
ClientAPI.CancelToken = CancelToken; ClientAPI.CancelToken = CancelToken;

View File

@@ -1,4 +1,5 @@
using Discord.API.Client.Rest; using Discord.API.Client.Rest;
using Discord.Logging;
using System; using System;
using System.Collections.Concurrent; using System.Collections.Concurrent;
using System.Net; using System.Net;
@@ -23,14 +24,17 @@ namespace Discord.Net
IsTTS = isTTS; IsTTS = isTTS;
} }
} }
private readonly Random _nonceRand; private readonly Random _nonceRand;
private readonly DiscordClient _client; private readonly DiscordClient _client;
private readonly Logger _logger;
private readonly ConcurrentQueue<MessageQueueItem> _pending; private readonly ConcurrentQueue<MessageQueueItem> _pending;
internal MessageQueue(DiscordClient client) internal MessageQueue(DiscordClient client, Logger logger)
{ {
_client = client; _client = client;
_logger = logger;
_nonceRand = new Random(); _nonceRand = new Random();
_pending = new ConcurrentQueue<MessageQueueItem>(); _pending = new ConcurrentQueue<MessageQueueItem>();
} }
@@ -78,6 +82,7 @@ namespace Discord.Net
} }
catch (WebException) { break; } catch (WebException) { break; }
catch (HttpException) { /*msg.State = MessageState.Failed;*/ } catch (HttpException) { /*msg.State = MessageState.Failed;*/ }
catch (Exception ex) { _logger.Error(ex); }
} }
} }
}); });