public async Task ReconnectAsync(Ec2Volume volume, InstanceClient client, CancellationToken?cancellationToken = null) { this.Client = client; this.Volume = volume; this.DisplayName = volume.Name; this.Volume.Logger = this.Logger; this.RunCommands = (await this.Client.GetRunCommandsAsync(this.Volume.MountPoint)).ToArray(); this.UserInstruction = (await this.Client.GetUserInstructionAsync(this.Volume.MountPoint)).Replace("<PUBLIC-IP>", this.Volume.Instance.PublicIp); this.Logger.Log("Reconnected to volume"); await this.UpdateScriptsAsync(); if (await this.Client.IsCommandSessionStartedAsync(this.Volume.MountPoint, cancellationToken)) { this.VolumeState = "started"; this.gameCts = new CancellationTokenSource(); await this.Client.ResumeSessionAsync(this.Volume.MountPoint, this.Logger, this.gameCts.Token); } else { this.VolumeState = "mounted"; } }
public async Task SetupAsync(Ec2Volume volume, InstanceClient client) { this.Client = client; this.Volume = volume; this.Volume.Logger = this.Logger; this.DisplayName = volume.Name; try { this.cancelCts = new CancellationTokenSource(); await this.Volume.SetupAsync(this.Client, this.cancelCts.Token); this.VolumeState = "mounted"; this.RunCommands = (await this.Client.GetRunCommandsAsync(this.Volume.MountPoint, this.cancelCts.Token)).ToArray(); this.UserInstruction = (await this.Client.GetUserInstructionAsync(this.Volume.MountPoint, this.cancelCts.Token)).Replace("<PUBLIC-IP>", this.Volume.Instance.PublicIp); await this.UpdateScriptsAsync(); } finally { this.CancelCts = null; } }