public static async new Task <ContainerExecResult> Create(API API, ContainerExec exec, JToken response, string operationUrl) { var result = new ContainerExecResultWithWebSockets(exec); var webSocketStrings = exec.Interactive ? new[] { "0", "control" } : new[] { "0", "1", "2", "control" }; var sockets = new List <ClientWebSocket>(); foreach (var i in webSocketStrings) { string fdsSecret = response.SelectToken($"metadata.metadata.fds.{i}").Value <string>(); string wsUrl = $"{API.BaseUrlWebSocket}{operationUrl}/websocket?secret={fdsSecret}"; sockets.Add(await ClientWebSocketExtensions.CreateAndConnectAsync(wsUrl, API)); } result.WebSockets = sockets.ToArray(); return(result); }
public static async Task <ContainerExecResult> Create(API API, ContainerExec exec, JToken response, string operationUrl) { if (exec.WaitForWebSocket) { response = API.Get(operationUrl); return(await ContainerExecResultWithWebSockets.Create(API, exec, response, operationUrl)); } else if (exec.Interactive == false && exec.RecordOutput) { response = API.Get(operationUrl); return(ContainerExecResultWithRecords.Create(API, exec, response, operationUrl)); } else { API.WaitForOperationComplete(response); return(new ContainerExecResult(exec)); } }