/// <summary> /// Helper method to start a session. /// </summary> private byte[] StartSession(bool serverSessionFlag, bool supportFlag, int windowHandle, String subject, UInt64 sessionID) { // Throw if we cannot open the session. if (AppVnc.SessionPresentFlag) { throw new Exception("a screen sharing session is already running"); } if (!IsOnlineCapable()) { throw new Exception("the " + KwmStrings.Kws + " is not connected to the server"); } // Remember that we have started a session. SessionPresentFlag = true; // Create the local session object. LocalSession = new VncLocalSession(this); LocalSession.ServerSessionFlag = serverSessionFlag; LocalSession.SupportSessionFlag = supportFlag; LocalSession.WindowHandle = windowHandle; LocalSession.Subject = subject; LocalSession.SessionID = sessionID; // Asynchronously start the session. KBase.ExecInUI(LocalSession.HandleNextSessionStep); Kws.OnStateChange(WmStateChange.Transient); return(LocalSession.SessionUuid); }
/// <summary> /// Complete the operation if we are ready to. /// </summary> private void CompleteIfNeeded() { if (DoneFlag || m_step != OpStep.LoggingIn || Kws.Cd.KcdState.LoginStatus != KwsLoginStatus.LoggedIn || Kws.Cd.MainStatus != KwsMainStatus.NotYetSpawned || Kws.Cd.CurrentTask != KwsTask.Spawn) { return; } // Update the main status of the workspace. Kws.Cd.MainStatus = KwsMainStatus.Good; Kws.OnStateChange(WmStateChange.Permanent); // Ask the state machine to work online. Kws.Sm.RequestTaskSwitch(KwsTask.WorkOnline); // Serialize the KWM so we don't lose the workspace if the KWM // crashes. Wm.Serialize(); // We're done. Complete(); }