/// <summary> /// Slurp a result according to the input command specified. The method /// throws an exception if it cannot slurp a valid result. The method /// sets outDesc to a string describing the result obtained and outMsg /// to the result obtained. /// </summary> public void Slurp(K3pCmd inCmd, out String outDesc, out K3pMsg outMsg) { outDesc = "unexpected result"; UInt32 outputIns = Ins(); if (outputIns == K3p.KMO_INVALID_REQ) throw new Exception("invalid request"); else if (outputIns == K3p.KMO_INVALID_CONFIG) { outMsg = new K3p.kmo_invalid_config(); outDesc = "invalid configuration"; } else if (outputIns == K3p.KMO_SERVER_ERROR) { K3p.kmo_server_error m = new K3p.kmo_server_error(); SlurpHelper(m, out outMsg); outDesc = "cannot contact "; String name = "server"; if (m.sid == K3p.kmo_server_error.Kmo_Sid.KMO_SID_KPS) name = "KPS"; else if (m.sid == K3p.kmo_server_error.Kmo_Sid.KMO_SID_OPS) name = "OPS"; else if (m.sid == K3p.kmo_server_error.Kmo_Sid.KMO_SID_OUS) name = "OUS"; else if (m.sid == K3p.kmo_server_error.Kmo_Sid.KMO_SID_OTS) name = "OTS"; else if (m.sid == K3p.kmo_server_error.Kmo_Sid.KMO_SID_IKS) name = "IKS"; else if (m.sid == K3p.kmo_server_error.Kmo_Sid.KMO_SID_EKS) name = "EKS"; outDesc += name + ": "; String reason = m.message; if (m.error == K3p.kmo_server_error.Kmo_Serror.KMO_SERROR_TIMEOUT) reason = "timeout occurred"; else if (m.error == K3p.kmo_server_error.Kmo_Serror.KMO_SERROR_UNREACHABLE) reason = "host unreachable"; outDesc += reason; } else if (outputIns == K3p.KMO_MUST_UPGRADE) { K3p.kmo_must_upgrade m = new K3p.kmo_must_upgrade(); SlurpHelper(m, out outMsg); outDesc = "must upgrade "; String what = "plugin"; if (m.what == K3p.KMO_UPGRADE_KPS) what = "KPS"; outDesc += what; } else if (outputIns == K3p.KMO_SERVER_INFO_ACK) SlurpHelper(new K3p.kmo_server_info_ack(), out outMsg); else if (outputIns == K3p.KMO_SERVER_INFO_NACK) SlurpHelper(new K3p.kmo_server_info_nack(), out outMsg); else if (inCmd is K3p.kpp_get_kws_ticket && outputIns == 0) SlurpHelper(new K3p.kmo_get_kws_ticket(), out outMsg); else if (inCmd is K3p.kpp_lookup_rec_addr && outputIns == 0) SlurpHelper(new K3p.kmo_lookup_rec_addr(), out outMsg); else throw new Exception("unexpected KMOD instruction " + outputIns); }
/// <summary> /// Slurp a result according to the input command specified. The method /// throws an exception if it cannot slurp a valid result. The method /// sets outDesc to a string describing the result obtained and outMsg /// to the result obtained. /// </summary> public void Slurp(K3pCmd inCmd, out String outDesc, out K3pMsg outMsg) { outDesc = "unexpected result"; UInt32 outputIns = Ins(); if (outputIns == K3p.KMO_INVALID_REQ) { throw new Exception("invalid request"); } else if (outputIns == K3p.KMO_INVALID_CONFIG) { outMsg = new K3p.kmo_invalid_config(); outDesc = "invalid configuration"; } else if (outputIns == K3p.KMO_SERVER_ERROR) { K3p.kmo_server_error m = new K3p.kmo_server_error(); SlurpHelper(m, out outMsg); outDesc = "cannot contact "; String name = "server"; if (m.sid == K3p.kmo_server_error.Kmo_Sid.KMO_SID_KPS) { name = "KPS"; } else if (m.sid == K3p.kmo_server_error.Kmo_Sid.KMO_SID_OPS) { name = "OPS"; } else if (m.sid == K3p.kmo_server_error.Kmo_Sid.KMO_SID_OUS) { name = "OUS"; } else if (m.sid == K3p.kmo_server_error.Kmo_Sid.KMO_SID_OTS) { name = "OTS"; } else if (m.sid == K3p.kmo_server_error.Kmo_Sid.KMO_SID_IKS) { name = "IKS"; } else if (m.sid == K3p.kmo_server_error.Kmo_Sid.KMO_SID_EKS) { name = "EKS"; } outDesc += name + ": "; String reason = m.message; if (m.error == K3p.kmo_server_error.Kmo_Serror.KMO_SERROR_TIMEOUT) { reason = "timeout occurred"; } else if (m.error == K3p.kmo_server_error.Kmo_Serror.KMO_SERROR_UNREACHABLE) { reason = "host unreachable"; } outDesc += reason; } else if (outputIns == K3p.KMO_MUST_UPGRADE) { K3p.kmo_must_upgrade m = new K3p.kmo_must_upgrade(); SlurpHelper(m, out outMsg); outDesc = "must upgrade "; String what = "plugin"; if (m.what == K3p.KMO_UPGRADE_KPS) { what = "KPS"; } outDesc += what; } else if (outputIns == K3p.KMO_SERVER_INFO_ACK) { SlurpHelper(new K3p.kmo_server_info_ack(), out outMsg); } else if (outputIns == K3p.KMO_SERVER_INFO_NACK) { SlurpHelper(new K3p.kmo_server_info_nack(), out outMsg); } else if (inCmd is K3p.kpp_get_kws_ticket && outputIns == 0) { SlurpHelper(new K3p.kmo_get_kws_ticket(), out outMsg); } else if (inCmd is K3p.kpp_lookup_rec_addr && outputIns == 0) { SlurpHelper(new K3p.kmo_lookup_rec_addr(), out outMsg); } else { throw new Exception("unexpected KMOD instruction " + outputIns); } }