mirror of
https://github.com/ppy/osu.git
synced 2025-01-14 03:25:11 +08:00
Fix chat connecting too early
This commit is contained in:
parent
1d2818dc70
commit
f12ada9d92
@ -111,6 +111,8 @@ namespace osu.Game.Online.Chat
|
||||
}
|
||||
});
|
||||
|
||||
connector.Start();
|
||||
|
||||
apiState.BindTo(api.State);
|
||||
apiState.BindValueChanged(_ => performChatAckRequest(), true);
|
||||
}
|
||||
|
@ -49,6 +49,9 @@ namespace osu.Game.Online
|
||||
this.api = api;
|
||||
this.versionHash = versionHash;
|
||||
this.preferMessagePack = preferMessagePack;
|
||||
|
||||
// Automatically start these connections.
|
||||
Start();
|
||||
}
|
||||
|
||||
protected override Task<PersistentEndpointClient> BuildConnectionAsync(CancellationToken cancellationToken)
|
||||
|
@ -29,6 +29,7 @@ namespace osu.Game.Online
|
||||
private readonly Bindable<bool> isConnected = new Bindable<bool>();
|
||||
private readonly SemaphoreSlim connectionLock = new SemaphoreSlim(1);
|
||||
private CancellationTokenSource connectCancelSource = new CancellationTokenSource();
|
||||
private bool started;
|
||||
|
||||
/// <summary>
|
||||
/// Constructs a new <see cref="PersistentEndpointClientConnector"/>.
|
||||
@ -37,9 +38,19 @@ namespace osu.Game.Online
|
||||
protected PersistentEndpointClientConnector(IAPIProvider api)
|
||||
{
|
||||
API = api;
|
||||
|
||||
apiState.BindTo(api.State);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Attempts to connect and begins processing messages from the remote endpoint.
|
||||
/// </summary>
|
||||
public void Start()
|
||||
{
|
||||
if (started)
|
||||
return;
|
||||
|
||||
apiState.BindValueChanged(_ => Task.Run(connectIfPossible), true);
|
||||
started = true;
|
||||
}
|
||||
|
||||
public Task Reconnect()
|
||||
|
Loading…
Reference in New Issue
Block a user