public void OnHandShakeRespond(KProtoBuf buf) { KG2C_HandshakeRespond respond = buf as KG2C_HandshakeRespond; KGateWayHandShakeCode code = EnumUtils.GetEnumIns <KGateWayHandShakeCode>(respond.code); log.Debug("网关握手返回:" + code); if (code == KGateWayHandShakeCode.ghcHandshakeSucceed) { KC2G_AccountVerifyRequest request = new KC2G_AccountVerifyRequest(); request.byProtocol = (byte)KC2G_Protocol.c2g_account_verify_request; log.Debug("Account=" + ConfigManager.GetInstance().Account); request.account = ConfigManager.GetInstance().Account; request.nGroupID = ConfigManager.GetInstance().GroupID; request.password = password; SendMessage(request); } else if (code == KGateWayHandShakeCode.ghcGatewayVersionError) { } }
/// <summary> /// 握手消息返回 /// </summary> /// <param name="buf"></param> public void OnHandShakeResponse(KProtoBuf buf) { KG2C_HandshakeRespond respond = buf as KG2C_HandshakeRespond; KGateWayHandShakeCode code = (KGateWayHandShakeCode)(respond.code); clientIP = respond.szClientIP; centerType = (KCenterType)respond.nTag; Debug.Log("OnHandShakeRespond centerType:" + centerType + ", result:" + code); if (respond.bReconnect > 0) { if (code == KGateWayHandShakeCode.ghcHandshakeSucceed) { Debug.Log("重连成功!"); uPlayerIndex = respond.uPlayerIndex; NetworkManager.Instance._SetHandshake(true); } else { Debug.Log("重连失败!"); uPlayerIndex = 0; HandShakeRequest(); } } else { if (code == KGateWayHandShakeCode.ghcHandshakeSucceed) { Debug.Log("网关握手成功!"); uPlayerIndex = respond.uPlayerIndex; AccountVerify(); } else { Debug.LogError("网关握手失败! RetCode:" + code); /// } } }