/// <summary> /// Creates a new <see cref="ConnectedClient"/> instance with new GUID /// identity and default "Lobby" group. /// </summary> /// <param name="connection">Client's connection.</param> /// <param name="cancellationToken">Cancellation token.</param> public async ValueTask <ConnectedClient> ConnectAsync(IConnection connection, CancellationToken cancellationToken) { var clientId = Guid.NewGuid().ToString(); var connectedClient = await _connectedClientFactory.CreateConnectedClientAsync(clientId, connection, cancellationToken) .ConfigureAwait(false); return(connectedClient); }
public async ValueTask <ConnectedClient> ConnectAsync(IConnection connection, CancellationToken cancellationToken) { var profileId = _connectedClientContext.GetProfile()?.ProfileId; if (profileId == null) { throw new InvalidOperationException("User token does not have a name."); } var connectedClient = await _connectedClientFactory.CreateConnectedClientAsync(profileId, connection, cancellationToken) .ConfigureAwait(false); return(connectedClient); }