mirror of
https://github.com/ppy/osu
synced 2025-02-15 17:47:28 +00:00
Merge pull request #16442 from peppy/fix-multiplayer-chat-polling
Fix chat poll rate being too low in multiplayer lobby and gameplay
This commit is contained in:
commit
70f56cd0c9
@ -90,13 +90,16 @@ namespace osu.Game.Online.Chat
|
||||
{
|
||||
// Polling will eventually be replaced with websocket, but let's avoid doing these background operations as much as possible for now.
|
||||
// The only loss will be delayed PM/message highlight notifications.
|
||||
int millisecondsBetweenPolls = HighPollRate.Value ? 1000 : 60000;
|
||||
|
||||
if (HighPollRate.Value)
|
||||
TimeBetweenPolls.Value = 1000;
|
||||
else if (!isIdle.Value)
|
||||
TimeBetweenPolls.Value = 60000;
|
||||
else
|
||||
TimeBetweenPolls.Value = 600000;
|
||||
if (isIdle.Value)
|
||||
millisecondsBetweenPolls *= 10;
|
||||
|
||||
if (TimeBetweenPolls.Value != millisecondsBetweenPolls)
|
||||
{
|
||||
TimeBetweenPolls.Value = millisecondsBetweenPolls;
|
||||
Logger.Log($"Chat is now polling every {TimeBetweenPolls.Value} ms");
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
@ -25,7 +25,7 @@ namespace osu.Game.Online.Chat
|
||||
|
||||
protected readonly ChatTextBox TextBox;
|
||||
|
||||
protected ChannelManager ChannelManager;
|
||||
private ChannelManager channelManager;
|
||||
|
||||
private StandAloneDrawableChannel drawableChannel;
|
||||
|
||||
@ -80,7 +80,7 @@ namespace osu.Game.Online.Chat
|
||||
[BackgroundDependencyLoader(true)]
|
||||
private void load(ChannelManager manager)
|
||||
{
|
||||
ChannelManager ??= manager;
|
||||
channelManager ??= manager;
|
||||
}
|
||||
|
||||
protected virtual StandAloneDrawableChannel CreateDrawableChannel(Channel channel) =>
|
||||
@ -94,9 +94,9 @@ namespace osu.Game.Online.Chat
|
||||
return;
|
||||
|
||||
if (text[0] == '/')
|
||||
ChannelManager?.PostCommand(text.Substring(1), Channel.Value);
|
||||
channelManager?.PostCommand(text.Substring(1), Channel.Value);
|
||||
else
|
||||
ChannelManager?.PostMessage(text, target: Channel.Value);
|
||||
channelManager?.PostMessage(text, target: Channel.Value);
|
||||
|
||||
TextBox.Text = string.Empty;
|
||||
}
|
||||
|
@ -820,7 +820,17 @@ namespace osu.Game
|
||||
|
||||
loadComponentSingleFile(CreateHighPerformanceSession(), Add);
|
||||
|
||||
chatOverlay.State.ValueChanged += state => channelManager.HighPollRate.Value = state.NewValue == Visibility.Visible;
|
||||
chatOverlay.State.BindValueChanged(_ => updateChatPollRate());
|
||||
// Multiplayer modes need to increase poll rate temporarily.
|
||||
API.Activity.BindValueChanged(_ => updateChatPollRate(), true);
|
||||
|
||||
void updateChatPollRate()
|
||||
{
|
||||
channelManager.HighPollRate.Value =
|
||||
chatOverlay.State.Value == Visibility.Visible
|
||||
|| API.Activity.Value is UserActivity.InLobby
|
||||
|| API.Activity.Value is UserActivity.InMultiplayerGame;
|
||||
}
|
||||
|
||||
Add(difficultyRecommender);
|
||||
Add(externalLinkOpener = new ExternalLinkOpener());
|
||||
|
Loading…
Reference in New Issue
Block a user