private void LogSessionStatus(RenderingSessionProperties sessionProperties) { Debug.Log($"Session '{sessionProperties.Id}' is {sessionProperties.Status}. Size={sessionProperties.Size}" + (!string.IsNullOrEmpty(sessionProperties.Hostname) ? $", Hostname='{sessionProperties.Hostname}'" : "") + (!string.IsNullOrEmpty(sessionProperties.Message) ? $", Message='{sessionProperties.Message}'" : "")); }
// start a new session or use an existing one, connect to it and then load the model public async void AutoStartSessionAsync() { try { CreateFrontend(); RenderingSessionProperties props = default(RenderingSessionProperties); bool hasSessionId = !string.IsNullOrEmpty(SessionId); string sessionId = SessionId; if (hasSessionId) { try { props = await arrService.OpenSession(SessionId); } catch (RRSessionException sessionException) { LogMessage($"Error opening session: {sessionException.Context.ErrorMessage}", true); } catch (RRException generalException) { LogMessage($"General error opening session: {generalException.ErrorCode}", true); } finally { SessionId = null; } } if (props.Status != RenderingSessionStatus.Ready) { if (hasSessionId) { LogMessage($"Session ID: {sessionId} is in state: {props.Status}. Starting a new session."); } props = await arrService.StartSession(new RenderingSessionCreationOptions(VMSize, (int)MaxLeaseTimeHours, (int)MaxLeaseTimeMinutes)); if (props.Status != RenderingSessionStatus.Ready) { LogMessage($"Session creation failed. Session status: {props.Status}.", true); return; } } SessionId = arrService.CurrentActiveSession.SessionUuid; if (!enabled) { return; } } catch (RRSessionException sessionException) { LogMessage($"Error creating session: {sessionException.Context.ErrorMessage}", true); } catch (RRException generalException) { LogMessage($"General error creating session: {generalException.ErrorCode}", true); } ConnectAndLoadModel(); }