More Bugfixes
This commit is contained in:
@@ -24,6 +24,7 @@ namespace Discord
|
||||
public string RecipientId { get; internal set; }
|
||||
public User Recipient { get { return _client.GetUser(RecipientId); } }
|
||||
|
||||
[JsonIgnore]
|
||||
public IEnumerable<Message> Messages { get { return _client.Messages.Where(x => x.ChannelId == Id); } }
|
||||
|
||||
//Not Implemented
|
||||
|
||||
@@ -343,7 +343,7 @@ namespace Discord
|
||||
case "MESSAGE_UPDATE":
|
||||
{
|
||||
var data = e.Event.ToObject<WebSocketEvents.MessageUpdate>();
|
||||
var msg = _messages.Update(data.Id, data);
|
||||
var msg = _messages.Update(data.Id, data.ChannelId, data);
|
||||
RaiseMessageUpdated(msg);
|
||||
}
|
||||
break;
|
||||
@@ -600,7 +600,7 @@ namespace Discord
|
||||
{
|
||||
int index = i * DiscordAPI.MaxMessageSize;
|
||||
var msg = await DiscordAPI.SendMessage(channelId, text.Substring(index, Math.Min(2000, text.Length - index)), mentions, _httpOptions);
|
||||
_messages.Update(msg.Id, msg);
|
||||
_messages.Update(msg.Id, channelId, msg);
|
||||
await Task.Delay(1000);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -23,13 +23,14 @@ namespace Discord
|
||||
private ConcurrentQueue<byte[]> _sendQueue;
|
||||
private int _heartbeatInterval;
|
||||
private DateTime _lastHeartbeat;
|
||||
private AutoResetEvent _connectWaitOnLogin;
|
||||
private AutoResetEvent _connectWaitOnLogin, _connectWaitOnLogin2;
|
||||
|
||||
public async Task ConnectAsync(string url, HttpOptions options)
|
||||
{
|
||||
await DisconnectAsync();
|
||||
|
||||
_connectWaitOnLogin = new AutoResetEvent(false);
|
||||
_connectWaitOnLogin2 = new AutoResetEvent(false);
|
||||
_sendQueue = new ConcurrentQueue<byte[]>();
|
||||
|
||||
_webSocket = new ClientWebSocket();
|
||||
@@ -66,8 +67,9 @@ namespace Discord
|
||||
msg.Payload.Properties["$referring_domain"] = "";
|
||||
SendMessage(msg, cancelToken);
|
||||
|
||||
if (!_connectWaitOnLogin.WaitOne(ReadyTimeout))
|
||||
if (!_connectWaitOnLogin.WaitOne(ReadyTimeout)) //Pre-Event
|
||||
throw new Exception("No reply from Discord server");
|
||||
_connectWaitOnLogin2.WaitOne(); //Post-Event
|
||||
}
|
||||
public async Task DisconnectAsync()
|
||||
{
|
||||
@@ -116,10 +118,11 @@ namespace Discord
|
||||
_heartbeatInterval = payload.HeartbeatInterval;
|
||||
SendMessage(new WebSocketCommands.UpdateStatus(), cancelToken);
|
||||
SendMessage(new WebSocketCommands.KeepAlive(), cancelToken);
|
||||
}
|
||||
_connectWaitOnLogin.Set(); //Pre-Event
|
||||
}
|
||||
RaiseGotEvent(msg.Type, msg.Payload as JToken);
|
||||
if (msg.Type == "READY")
|
||||
_connectWaitOnLogin.Set();
|
||||
_connectWaitOnLogin2.Set(); //Post-Event
|
||||
break;
|
||||
default:
|
||||
RaiseOnDebugMessage("Unknown WebSocket operation ID: " + msg.Operation);
|
||||
|
||||
Reference in New Issue
Block a user