protected override async Task OnExecuteAsync(CommandLineApplication app) { if (String.IsNullOrEmpty(GroupName)) { Console.WriteLine("Missing groupName parameter"); return; } var cli = new SyncClient(this.TransportHubUrl); var tcs = new TaskCompletionSource <object>(); var userId = GenRandomName(8); var secondNotificationHub = await cli.ConnectToHub(false, GroupName, userId, tcs); await tcs.Task; // waiting until it gets the target URL and access token. TODO: a time out is required. var info = cli.InfoToTransportHub; var secondTransportHubConnection = await cli.DirectConnectToTransportHub(info); Console.WriteLine("Press Ctrl+C to stop"); await WaitUntilCancel(); await SyncClient.LeaveNegotiationGroupAsync(secondNotificationHub, GroupName); await secondNotificationHub.StopAsync(); await secondTransportHubConnection.StopAsync(); }
protected override async Task OnExecuteAsync(CommandLineApplication app) { var groupName = GenRandomName(this.GroupNameLength); var cli = new SyncClient(this.TransportHubUrl); var firstHub = await cli.ConnectToHub(true, groupName, null, null); Console.WriteLine($"Group for sync: {groupName}"); Console.WriteLine("Press Ctrl+C to stop"); await WaitUntilCancel(); // stop all connections. await SyncClient.LeaveNegotiationGroupAsync(firstHub, groupName); await firstHub.StopAsync(); }