mirror of https://github.com/ppy/osu
Fix chat connecting too early
This commit is contained in:
parent
1d2818dc70
commit
f12ada9d92
|
@ -111,6 +111,8 @@ private void load()
|
|||
}
|
||||
});
|
||||
|
||||
connector.Start();
|
||||
|
||||
apiState.BindTo(api.State);
|
||||
apiState.BindValueChanged(_ => performChatAckRequest(), true);
|
||||
}
|
||||
|
|
|
@ -49,6 +49,9 @@ public HubClientConnector(string clientName, string endpoint, IAPIProvider api,
|
|||
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 @@ public abstract class PersistentEndpointClientConnector : IDisposable
|
|||
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 @@ public abstract class PersistentEndpointClientConnector : IDisposable
|
|||
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