/// <summary> /// This method is called when the ticket query has completed. /// </summary> private void OnTicketReply(KcdQuery query) { if (Status != VncSessionStatus.Ticket) { return; } TicketQuery = null; try { AnpMsg m = query.Res; if (m.Type == KAnp.KANP_RES_VNC_START_TICKET || m.Type == KAnp.KANP_RES_VNC_CONNECT_TICKET) { Ticket = m.Elements[0].Bin; HandleNextSessionStep(); } else { throw EAnpException.FromKAnpReply(m); } } catch (Exception ex) { HandleSessionTrouble(ex); } }
/// <summary> /// Called when the login reply is received. /// </summary> private void HandleConnectKwsReply(KcdQuery query) { KLogging.Log("Got login reply, kws " + m_kws.InternalID + ", status " + m_kws.Cd.MainStatus); Debug.Assert(m_ks.LoginStatus == KwsLoginStatus.LoggingIn); // This is the standard login reply. if (query.Res.Type == KAnp.KANP_RES_KWS_CONNECT_KWS) { // Get the provided information. KwsConnectRes r = new KwsConnectRes(query.Res); KLogging.Log(m_currentStep + " login step: " + r.ErrMsg); // Dispatch. if (r.Code == KAnp.KANP_KWS_LOGIN_OK) { HandleConnectKwsSuccess(r); } else if (r.Code == KAnp.KANP_KWS_LOGIN_BAD_PWD_OR_TICKET) { HandleBadPwdOrTicket(r); } else { HandleLoginFailure(TranslateKcdLoginStatusCode(r.Code), new Exception(r.ErrMsg)); } } // This is an unexpected reply. else { HandleLoginFailure(KwsLoginResult.MiscKcdError, EAnpException.FromKAnpReply(query.Res)); } }
/// <summary> /// Handle the result of the commands. /// </summary> protected virtual void HandleCmdResult(AnpMsg res) { if (res.Type != KAnp.KANP_RES_OK) { throw EAnpException.FromKAnpReply(res); } }
/// <summary> /// Negociate the role. /// </summary> private void NegociateRole() { AnpMsg m = CreateAnpMsg(KAnp.KANP_CMD_MGT_SELECT_ROLE); m.AddUInt32(KAnp.KANP_KCD_ROLE_APP_SHARE); SendAnpMsg(m); m = GetAnpMsg(); if (m.Type == KAnp.KANP_RES_FAIL) { throw EAnpException.FromKAnpReply(m); } if (m.Type != KAnp.KANP_RES_OK) { throw new Exception("expected RES_OK in role negociation"); } }
/// <summary> /// Called when the create workspace command reply is received. /// </summary> private void HandleCreateKwsCmdResult(KcdQuery query) { if (m_kcdQuery != query) { return; } m_kcdQuery = null; Debug.Assert(m_step == OpStep.CreateReply); try { AnpMsg res = query.Res; // Failure. if (res.Type != KAnp.KANP_RES_MGT_KWS_CREATED) { throw EAnpException.FromKAnpReply(res); } // Parse the reply. UInt64 externalID = res.Elements[0].UInt64; String emailID = res.Elements[1].String; // Validate that the KCD is not screwing with us. This can // happen if the KCD state has been reverted. if (Wm.GetKwsByExternalID(Kws.Kcd.KcdID, externalID) != null) { throw new Exception("duplicate " + KwmStrings.Kws + " external ID"); } // Update the workspace credentials. Creds.ExternalID = externalID; Creds.EmailID = emailID; // Wait for login. m_step = OpStep.LoggingIn; Kws.Sm.SetLoginType(KwsLoginType.Cached); Kws.Sm.SetSpawnStep(KwsSpawnTaskStep.Login); } catch (Exception ex) { HandleFailure(ex); } }
protected override void HandleCmdResult(AnpMsg res) { if (res.Type != KAnp.KANP_RES_KWS_INVITE_KWS) { throw EAnpException.FromKAnpReply(res); } int i = 0; Wleu = res.Elements[i++].String; i++; foreach (User u in UserList) { u.EmailID = res.Elements[i++].String; u.Url = res.Elements[i++].String; u.Error = res.Elements[i++].String; } }
/// <summary> /// Negociate the session. /// </summary> private void NegociateSession() { AnpMsg m = null; if (m_session.ServerSessionFlag) { m = CreateAnpMsg(KAnp.KANP_CMD_VNC_START_SESSION); m.AddBin(m_session.Ticket); m.AddString(m_session.Subject); } else { m = CreateAnpMsg(KAnp.KANP_CMD_VNC_CONNECT_SESSION); m.AddBin(m_session.Ticket); } SendAnpMsg(m); m = GetAnpMsg(); if (m_session.ServerSessionFlag) { if (m.Type != KAnp.KANP_RES_VNC_START_SESSION) { throw EAnpException.FromKAnpReply(m); } m_session.SessionID = m.Elements[0].UInt64; } else { if (m.Type != KAnp.KANP_RES_OK) { throw EAnpException.FromKAnpReply(m); } } }