mirror of
https://github.com/ppy/osu.git
synced 2024-11-11 14:17:26 +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.BindTo(api.State);
|
||||||
apiState.BindValueChanged(_ => performChatAckRequest(), true);
|
apiState.BindValueChanged(_ => performChatAckRequest(), true);
|
||||||
}
|
}
|
||||||
|
@ -49,6 +49,9 @@ namespace osu.Game.Online
|
|||||||
this.api = api;
|
this.api = api;
|
||||||
this.versionHash = versionHash;
|
this.versionHash = versionHash;
|
||||||
this.preferMessagePack = preferMessagePack;
|
this.preferMessagePack = preferMessagePack;
|
||||||
|
|
||||||
|
// Automatically start these connections.
|
||||||
|
Start();
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override Task<PersistentEndpointClient> BuildConnectionAsync(CancellationToken cancellationToken)
|
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 Bindable<bool> isConnected = new Bindable<bool>();
|
||||||
private readonly SemaphoreSlim connectionLock = new SemaphoreSlim(1);
|
private readonly SemaphoreSlim connectionLock = new SemaphoreSlim(1);
|
||||||
private CancellationTokenSource connectCancelSource = new CancellationTokenSource();
|
private CancellationTokenSource connectCancelSource = new CancellationTokenSource();
|
||||||
|
private bool started;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Constructs a new <see cref="PersistentEndpointClientConnector"/>.
|
/// Constructs a new <see cref="PersistentEndpointClientConnector"/>.
|
||||||
@ -37,9 +38,19 @@ namespace osu.Game.Online
|
|||||||
protected PersistentEndpointClientConnector(IAPIProvider api)
|
protected PersistentEndpointClientConnector(IAPIProvider api)
|
||||||
{
|
{
|
||||||
API = api;
|
API = api;
|
||||||
|
|
||||||
apiState.BindTo(api.State);
|
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);
|
apiState.BindValueChanged(_ => Task.Run(connectIfPossible), true);
|
||||||
|
started = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Task Reconnect()
|
public Task Reconnect()
|
||||||
|
Loading…
Reference in New Issue
Block a user