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:
Dan Balasescu 2022-01-14 13:52:37 +09:00 committed by GitHub
commit 70f56cd0c9
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 24 additions and 11 deletions

View File

@ -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. // 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. // The only loss will be delayed PM/message highlight notifications.
int millisecondsBetweenPolls = HighPollRate.Value ? 1000 : 60000;
if (HighPollRate.Value) if (isIdle.Value)
TimeBetweenPolls.Value = 1000; millisecondsBetweenPolls *= 10;
else if (!isIdle.Value)
TimeBetweenPolls.Value = 60000; if (TimeBetweenPolls.Value != millisecondsBetweenPolls)
else {
TimeBetweenPolls.Value = 600000; TimeBetweenPolls.Value = millisecondsBetweenPolls;
Logger.Log($"Chat is now polling every {TimeBetweenPolls.Value} ms");
}
} }
/// <summary> /// <summary>

View File

@ -25,7 +25,7 @@ namespace osu.Game.Online.Chat
protected readonly ChatTextBox TextBox; protected readonly ChatTextBox TextBox;
protected ChannelManager ChannelManager; private ChannelManager channelManager;
private StandAloneDrawableChannel drawableChannel; private StandAloneDrawableChannel drawableChannel;
@ -80,7 +80,7 @@ namespace osu.Game.Online.Chat
[BackgroundDependencyLoader(true)] [BackgroundDependencyLoader(true)]
private void load(ChannelManager manager) private void load(ChannelManager manager)
{ {
ChannelManager ??= manager; channelManager ??= manager;
} }
protected virtual StandAloneDrawableChannel CreateDrawableChannel(Channel channel) => protected virtual StandAloneDrawableChannel CreateDrawableChannel(Channel channel) =>
@ -94,9 +94,9 @@ namespace osu.Game.Online.Chat
return; return;
if (text[0] == '/') if (text[0] == '/')
ChannelManager?.PostCommand(text.Substring(1), Channel.Value); channelManager?.PostCommand(text.Substring(1), Channel.Value);
else else
ChannelManager?.PostMessage(text, target: Channel.Value); channelManager?.PostMessage(text, target: Channel.Value);
TextBox.Text = string.Empty; TextBox.Text = string.Empty;
} }

View File

@ -820,7 +820,17 @@ namespace osu.Game
loadComponentSingleFile(CreateHighPerformanceSession(), Add); 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(difficultyRecommender);
Add(externalLinkOpener = new ExternalLinkOpener()); Add(externalLinkOpener = new ExternalLinkOpener());