Merged changed from dev branch

This commit is contained in:
RogueException
2016-09-22 21:31:48 -03:00
19 changed files with 167 additions and 64 deletions

View File

@@ -38,7 +38,7 @@ namespace Discord.WebSocket
private int _nextAudioId;
private bool _canReconnect;
/// <summary> Gets the shard if of this client. </summary>
/// <summary> Gets the shard of of this client. </summary>
public int ShardId { get; }
/// <summary> Gets the current connection state of this client. </summary>
public ConnectionState ConnectionState { get; private set; }
@@ -793,6 +793,7 @@ namespace Discord.WebSocket
if (guild != null)
{
guild.AddChannel(data, DataStore);
channel = guild.AddChannel(data, DataStore);
if (!guild.IsSynced)
{
@@ -1263,6 +1264,12 @@ namespace Discord.WebSocket
}
if (after != null)
await _messageUpdatedEvent.InvokeAsync(Optional.Create(before), after).ConfigureAwait(false);
{
if (before != null)
await _messageUpdatedEvent.InvokeAsync(Optional.Create<IMessage>(before), after).ConfigureAwait(false);
else
await _messageUpdatedEvent.InvokeAsync(Optional.Create<IMessage>(), after).ConfigureAwait(false);
}
}
else
{

View File

@@ -148,11 +148,12 @@ namespace Discord.WebSocket
public override Task<IGuildChannel> GetChannelAsync(ulong id) => Task.FromResult<IGuildChannel>(GetChannel(id));
public override Task<IReadOnlyCollection<IGuildChannel>> GetChannelsAsync() => Task.FromResult<IReadOnlyCollection<IGuildChannel>>(Channels);
public void AddChannel(ChannelModel model, DataStore dataStore, ConcurrentHashSet<ulong> channels = null)
public ISocketGuildChannel AddChannel(ChannelModel model, DataStore dataStore, ConcurrentHashSet<ulong> channels = null)
{
var channel = ToChannel(model);
(channels ?? _channels).TryAdd(model.Id);
dataStore.AddChannel(channel);
return channel;
}
public ISocketGuildChannel GetChannel(ulong id)
{

View File

@@ -8,6 +8,7 @@ namespace Discord.WebSocket
internal class SocketGlobalUser : User, ISocketUser
{
internal override bool IsAttached => true;
private readonly object _lockObj = new object();
private ushort _references;
@@ -25,13 +26,13 @@ namespace Discord.WebSocket
{
checked
{
lock (this)
lock (_lockObj)
_references++;
}
}
public void RemoveRef(DiscordSocketClient discord)
{
lock (this)
lock (_lockObj)
{
if (--_references == 0)
discord.RemoveUser(Id);
@@ -40,16 +41,16 @@ namespace Discord.WebSocket
public override void Update(Model model)
{
lock (this)
lock (_lockObj)
base.Update(model, source);
}
public void Update(PresenceModel model)
{
//Race conditions are okay here. Multiple shards racing already cant guarantee presence in order.
//lock (this)
//lock (_lockObj)
//{
var game = model.Game != null ? new Game(model.Game) : null;
var game = model.Game != null ? new Game(model.Game) : null;
Presence = new Presence(game, model.Status);
//}
}

View File

@@ -1,11 +1,10 @@
{
"version": "1.0.0-*",
"version": "1.0.0-beta2-*",
"buildOptions": {
"compile": {
"include": [ "../Discord.Net.Entities/**.cs", "../Discord.Net.Utils/**.cs" ]
},
"define": [ "WEBSOCKET" ]
"include": [ "../Discord.Net.Utils/**.cs" ]
}
},
"dependencies": {