mirror of
https://github.com/ppy/osu.git
synced 2024-12-14 20:22:55 +08:00
Add message batching per-channel.
This commit is contained in:
parent
729f2eec8d
commit
7a2eedbd7e
@ -3,12 +3,7 @@
|
|||||||
|
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Diagnostics;
|
|
||||||
using System.Linq;
|
|
||||||
using Newtonsoft.Json;
|
using Newtonsoft.Json;
|
||||||
using osu.Framework.Configuration;
|
|
||||||
using osu.Game.Online.API;
|
|
||||||
using osu.Game.Online.API.Requests;
|
|
||||||
|
|
||||||
namespace osu.Game.Online.Chat
|
namespace osu.Game.Online.Chat
|
||||||
{
|
{
|
||||||
@ -37,9 +32,9 @@ namespace osu.Game.Online.Chat
|
|||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
public event Action<Message[]> NewMessagesArrived;
|
public event Action<IEnumerable<Message>> NewMessagesArrived;
|
||||||
|
|
||||||
public void AddNewMessages(params Message[] messages)
|
public void AddNewMessages(IEnumerable<Message> messages)
|
||||||
{
|
{
|
||||||
Messages.AddRange(messages);
|
Messages.AddRange(messages);
|
||||||
purgeOldMessages();
|
purgeOldMessages();
|
||||||
|
@ -113,10 +113,11 @@ namespace osu.Game.Overlays
|
|||||||
fetchReq = new GetMessagesRequest(careChannels, lastMessageId);
|
fetchReq = new GetMessagesRequest(careChannels, lastMessageId);
|
||||||
fetchReq.Success += delegate (List<Message> messages)
|
fetchReq.Success += delegate (List<Message> messages)
|
||||||
{
|
{
|
||||||
foreach (Message m in messages)
|
var ids = messages.Select(m => m.ChannelId).Distinct();
|
||||||
{
|
|
||||||
careChannels.Find(c => c.Id == m.ChannelId).AddNewMessages(m);
|
//batch messages per channel.
|
||||||
}
|
foreach (var id in ids)
|
||||||
|
careChannels.Find(c => c.Id == id)?.AddNewMessages(messages.Where(m => m.ChannelId == id));
|
||||||
|
|
||||||
lastMessageId = messages.LastOrDefault()?.Id ?? lastMessageId;
|
lastMessageId = messages.LastOrDefault()?.Id ?? lastMessageId;
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user