public int GameFuBenRoleChangeState(int roleId, int state, int serverId = 0, int gameId = 0) { try { IKuaFuService kuaFuService = this.GetKuaFuService(false); if (null != kuaFuService) { if (serverId <= 0 || gameId <= 0) { KuaFuRoleData kuaFuRoleData; if (!this.RoleId2RoleDataDict.TryGetValue(roleId, out kuaFuRoleData)) { return(0); } serverId = kuaFuRoleData.ServerId; gameId = kuaFuRoleData.GameId; } return(this.KuaFuService.GameFuBenRoleChangeState(serverId, roleId, gameId, state)); } } catch (Exception ex) { LogManager.WriteExceptionUseCache(ex.ToString()); } return(0); }
/// <summary> /// 游戏副本状态变更 /// </summary> /// <param name="gameId"></param> /// <param name="state"></param> /// <param name="time"></param> /// <returns></returns> public int GameFuBenChangeState(int gameId, GameFuBenState state, DateTime time) { int result = StdErrorCode.Error_Operation_Faild; IKuaFuService kuaFuService = null; HuanYingSiYuanFuBenData huanYingSiYuanFuBenData = null; if (HuanYingSiYuanFuBenDataDict.TryGetValue(gameId, out huanYingSiYuanFuBenData)) { lock (huanYingSiYuanFuBenData) { huanYingSiYuanFuBenData.State = state; if (state == GameFuBenState.End) { RemoveGameFuBen(huanYingSiYuanFuBenData, null); } } } else { return(StdErrorCode.Error_Not_Exist); } return(result); }
/// <summary> /// 游戏副本状态变更 /// </summary> /// <param name="gameId"></param> /// <param name="state"></param> /// <param name="time"></param> /// <returns></returns> public int GameFuBenChangeState(int gameId, GameFuBenState state, DateTime time) { int result = StdErrorCode.Error_Operation_Faild; IKuaFuService kuaFuService = null; TianTiFuBenData tianTiFuBenData = null; if (TianTiFuBenDataDict.TryGetValue(gameId, out tianTiFuBenData)) { AddRolePairFightCount(tianTiFuBenData); lock (tianTiFuBenData) { tianTiFuBenData.State = state; if (state == GameFuBenState.End) { RemoveGameFuBen(tianTiFuBenData); } } } else { return(StdErrorCode.Error_Not_Exist); } return(result); }
private void ResetKuaFuService() { RemoteServiceUri = CoreInterface.GetRuntimeVariable(RuntimeVariableNames.HuanYingSiYuanUri, null); lock (Mutex) { KuaFuService = null; } }
public int HuanYingSiYuanSignUp(string userId, int roleId, int zoneId, int gameType, int groupIndex, int zhanDouLi) { int result2; if (string.IsNullOrEmpty(userId) || roleId <= 0) { result2 = -20; } else { userId = userId.ToUpper(); int count = Interlocked.Increment(ref this.CurrentRequestCount); try { if (count < this.MaxRequestCount) { lock (this.Mutex) { KuaFuRoleData kuaFuRoleData; if (this.RoleId2RoleDataDict.TryGetValue(roleId, out kuaFuRoleData)) { if (kuaFuRoleData.ServerId != this.ClientInfo.ServerId) { return(-11); } } } IKuaFuService kuaFuService = this.GetKuaFuService(false); if (null == kuaFuService) { return(-11001); } try { IGameData huanYingSiYuanGameData = new IGameData { ZhanDouLi = zhanDouLi }; int result = kuaFuService.RoleSignUp(this.ClientInfo.ServerId, userId, zoneId, roleId, gameType, groupIndex, huanYingSiYuanGameData); } catch (Exception ex) { this.ResetKuaFuService(); } } } catch (Exception ex) { LogManager.WriteExceptionUseCache(ex.ToString()); } finally { Interlocked.Decrement(ref this.CurrentRequestCount); } result2 = 1; } return(result2); }
public void TimerProc(object sender, EventArgs e) { try { string huanYingSiYuanUri = CoreInterface.GetRuntimeVariable(RuntimeVariableNames.HuanYingSiYuanUri, null); if (RemoteServiceUri != huanYingSiYuanUri) { RemoteServiceUri = huanYingSiYuanUri; } IKuaFuService kuaFuService = GetKuaFuService(); if (null != kuaFuService) { if (ClientInfo.ClientId > 0) { List <KuaFuServerInfo> dict = kuaFuService.GetKuaFuServerInfoData(ServerInfoAsyncAge); if (null != dict && dict.Count > 0) { lock (Mutex) { ServerIdServerInfoDict.Clear(); bool first = true; foreach (var item in dict) { ServerIdServerInfoDict[item.ServerId] = item; if (first) { first = false; ServerInfoAsyncAge = item.Age; } if (ClientInfo.ServerId == item.ServerId) { LocalServerFlags = item.Flags; } } } } //同步数据 AsyncDataItem[] items = kuaFuService.GetClientCacheItems(ClientInfo.ServerId); if (null != items && items.Length > 0) { //ThreadPool.QueueUserWorkItem(new WaitCallback(ExecuteEventCallBackAsync), items); ExecuteEventCallBackAsync(items); } } } } catch (System.Exception ex) { ResetKuaFuService(); } }
public byte[] GetRoleData_KuaFuLueDuo(long rid) { IKuaFuService kuaFuService = this.GetKuaFuService(false); if (null != kuaFuService) { try { return(kuaFuService.GetRoleData_KuaFuLueDuo(rid)); } catch (Exception ex) { LogManager.WriteException(ex.ToString()); } } return(null); }
public KuaFuLueDuoFuBenData GetFuBenDataByGameId_KuaFuLueDuo(long gameId) { IKuaFuService kuaFuService = this.GetKuaFuService(false); if (null != kuaFuService) { try { return(kuaFuService.GetFuBenDataByGameId_KuaFuLueDuo(gameId)); } catch (Exception ex) { LogManager.WriteException(ex.ToString()); } } return(null); }
public int GameFuBenComplete_KuaFuLueDuo(KuaFuLueDuoStatisticalData data) { IKuaFuService kuaFuService = this.GetKuaFuService(false); if (null != kuaFuService) { try { return(kuaFuService.GameFuBenComplete_KuaFuLueDuo(data)); } catch (Exception ex) { this.ResetKuaFuService(); } } return(-11000); }
public KuaFuLueDuoJingJiaResult JingJia_KuaFuLueDuo(int bhid, int zoneid_bh, string bhname, int ziJin, int serverId, int oldZiJin) { IKuaFuService kuaFuService = this.GetKuaFuService(false); if (null != kuaFuService) { try { return(kuaFuService.JingJia_KuaFuLueDuo(bhid, zoneid_bh, bhname, ziJin, serverId, oldZiJin)); } catch (Exception ex) { LogManager.WriteException(ex.ToString()); } } return(-11000); }
public int ChangeRoleState(int roleId, KuaFuRoleStates state, bool noWait = false) { int result = StdErrorCode.Error_Operation_Faild; IKuaFuService kuaFuService = null; KuaFuRoleData kuaFuRoleData = null; int serverId = ClientInfo.ServerId; lock (Mutex) { if (RoleId2RoleDataDict.TryGetValue(roleId, out kuaFuRoleData)) { serverId = kuaFuRoleData.ServerId; } } kuaFuService = GetKuaFuService(noWait); if (null != kuaFuService) { try { result = kuaFuService.RoleChangeState(serverId, roleId, (int)state); if (result >= 0) { lock (Mutex) { if (RoleId2RoleDataDict.TryGetValue(roleId, out kuaFuRoleData)) { kuaFuRoleData.State = (KuaFuRoleStates)result; } } if (null != kuaFuRoleData) { UpdateRoleData(kuaFuRoleData); } } } catch (System.Exception ex) { result = StdErrorCode.Error_Server_Internal_Error; } } return(result); }
public int RoleChangeState(int serverId, int rid, int state) { int result = -11; IKuaFuService kuaFuService = this.GetKuaFuService(false); if (null != kuaFuService) { try { result = kuaFuService.RoleChangeState(serverId, rid, state); } catch (Exception ex) { this.ResetKuaFuService(); } } return(result); }
public int GameFuBenChangeState(int gameId, GameFuBenState state, DateTime time) { int result = -11000; IKuaFuService kuaFuService = this.GetKuaFuService(false); if (null != kuaFuService) { try { result = kuaFuService.GameFuBenChangeState(gameId, state, time); } catch (Exception ex) { this.ResetKuaFuService(); result = -11003; } } return(result); }
public KuaFuRoleData GetKuaFuRoleDataFromServer(int serverId, int roleId) { KuaFuRoleData kuaFuRoleData = null; IKuaFuService kuaFuService = this.GetKuaFuService(false); if (null != kuaFuService) { try { kuaFuRoleData = kuaFuService.GetKuaFuRoleData(serverId, roleId); this.UpdateRoleData(kuaFuRoleData, 0); } catch (Exception ex) { kuaFuRoleData = null; } } return(kuaFuRoleData); }
public KuaFuLueDuoBHData GetBHDataByBhid_KuaFuLueDuo(int bhid) { IKuaFuService kuaFuService = this.GetKuaFuService(false); if (null != kuaFuService) { try { lock (this.Mutex) { KuaFuData <KuaFuLueDuoBHData> bhdata = null; if (!this.KuaFuLueDuoBHDataDict.TryGetValue(bhid, out bhdata)) { bhdata = new KuaFuData <KuaFuLueDuoBHData>(); this.KuaFuLueDuoBHDataDict[bhid] = bhdata; } KuaFuCmdData result = kuaFuService.GetBHDataByBhid_KuaFuLueDuo(bhid, bhdata.Age); if (result == null || result.Age < 0L) { return(null); } if (result != null && result.Age > bhdata.Age) { bhdata.Age = result.Age; if (null != result.Bytes0) { bhdata.V = DataHelper2.BytesToObject <KuaFuLueDuoBHData>(result.Bytes0, 0, result.Bytes0.Length); } if (null != bhdata.V) { this.KuaFuLueDuoBHDataDict[bhid] = bhdata; } } return(bhdata.V); } } catch (Exception ex) { LogManager.WriteException(ex.ToString()); } } return(null); }
public int ChangeRoleState(int roleId, KuaFuRoleStates state, bool noWait = false) { int result = -11; KuaFuRoleData kuaFuRoleData = null; int serverId = this.ClientInfo.ServerId; lock (this.Mutex) { if (this.RoleId2RoleDataDict.TryGetValue(roleId, out kuaFuRoleData)) { serverId = kuaFuRoleData.ServerId; } } IKuaFuService kuaFuService = this.GetKuaFuService(noWait); if (null != kuaFuService) { try { result = kuaFuService.RoleChangeState(serverId, roleId, (int)state); if (result >= 0) { lock (this.Mutex) { if (this.RoleId2RoleDataDict.TryGetValue(roleId, out kuaFuRoleData)) { kuaFuRoleData.State = (KuaFuRoleStates)result; } } if (null != kuaFuRoleData) { this.UpdateRoleData(kuaFuRoleData, 0); } } } catch (Exception ex) { result = -11003; } } return(result); }
/// <summary> /// 从服务器获取角色数据 /// </summary> /// <param name="serverId"></param> /// <param name="roleId"></param> /// <returns></returns> public KuaFuRoleData GetKuaFuRoleDataFromServer(int serverId, int roleId) { KuaFuRoleData kuaFuRoleData = null; IKuaFuService kuaFuService = GetKuaFuService(); if (null != kuaFuService) { try { kuaFuRoleData = (KuaFuRoleData)kuaFuService.GetKuaFuRoleData(serverId, roleId); UpdateRoleData(kuaFuRoleData); //更新 } catch (System.Exception ex) { kuaFuRoleData = null; } } return(kuaFuRoleData); }
/// <summary> /// 角色状态修改 /// </summary> /// <param name="rid"></param> /// <param name="gameType"></param> /// <param name="groupIndex"></param> /// <param name="state"></param> /// <returns></returns> public int RoleChangeState(int serverId, int rid, int state) { int result = StdErrorCode.Error_Operation_Faild; IKuaFuService kuaFuService = GetKuaFuService(); if (null != kuaFuService) { try { result = kuaFuService.RoleChangeState(serverId, rid, state); } catch (System.Exception ex) { ResetKuaFuService(); } } return(result); }
public int GetRoleKuaFuFuBenRoleCount(int roleId) { int roleCount = 0; try { IKuaFuService kuaFuService = this.GetKuaFuService(false); if (null != kuaFuService) { int result = kuaFuService.GetRoleExtendData(this.ClientInfo.ServerId, roleId, 0); bool flag = 1 == 0; roleCount = result; } } catch (Exception ex) { LogManager.WriteExceptionUseCache(ex.ToString()); } return(roleCount); }
/// <summary> /// 游戏副本状态变更 /// </summary> /// <param name="gameId"></param> /// <param name="state"></param> /// <param name="time"></param> /// <returns></returns> public int GameFuBenChangeState(int gameId, GameFuBenState state, DateTime time) { int result = StdErrorCode.Error_Server_Busy; IKuaFuService kuaFuService = GetKuaFuService(); if (null != kuaFuService) { try { result = kuaFuService.GameFuBenChangeState(gameId, state, time); } catch (System.Exception ex) { ResetKuaFuService(); result = StdErrorCode.Error_Server_Internal_Error; } } return(result); }
public KuaFuLueDuoSyncData SyncData_KuaFuLueDuo(KuaFuLueDuoSyncData SyncData) { IKuaFuService kuaFuService = this.GetKuaFuService(false); if (null != kuaFuService) { try { byte[] result = kuaFuService.SyncData_KuaFuLueDuo(DataHelper.ObjectToBytes <KuaFuLueDuoSyncData>(SyncData)); if (null != result) { return(DataHelper.BytesToObject <KuaFuLueDuoSyncData>(result, 0, result.Length)); } } catch (Exception ex) { this.ResetKuaFuService(); } } return(null); }
private HuanYingSiYuanFuBenData GetKuaFuFuBenData(int gameId) { HuanYingSiYuanFuBenData huanYingSiYuanFuBenData = null; if (huanYingSiYuanFuBenData == null) { IKuaFuService kuaFuService = this.GetKuaFuService(false); if (null != kuaFuService) { try { huanYingSiYuanFuBenData = kuaFuService.GetFuBenData(gameId); } catch (Exception ex) { LogManager.WriteException(ex.ToString()); huanYingSiYuanFuBenData = null; } } } return(huanYingSiYuanFuBenData); }
public void BroadcastGMCmdData(GMCmdData data, int serverFlag) { try { IKuaFuService kuaFuService = this.GetKuaFuService(false); if (null != kuaFuService) { try { kuaFuService.BroadcastGMCmdData(data, serverFlag); } catch (Exception ex) { this.ResetKuaFuService(); } } } catch (Exception ex) { LogManager.WriteException(ex.ToString()); } }
public void TimerProc(object sender, EventArgs e) { try { string huanYingSiYuanUri = this.CoreInterface.GetRuntimeVariable("HuanYingSiYuanUri", null); if (this.RemoteServiceUri != huanYingSiYuanUri) { this.RemoteServiceUri = huanYingSiYuanUri; } IKuaFuService kuaFuService = this.GetKuaFuService(false); if (null != kuaFuService) { if (this.ClientInfo.ClientId > 0) { List <KuaFuServerInfo> dict = kuaFuService.GetKuaFuServerInfoData(KuaFuManager.getInstance().GetServerInfoAsyncAge()); KuaFuManager.getInstance().UpdateServerInfoList(dict); AsyncData asyncData = kuaFuService.GetClientCacheItems2(this.ClientInfo.ServerId, TimeUtil.NOW()); long nowTicks = TimeUtil.NOW(); long subTicks = nowTicks - asyncData.RequestTicks; if (subTicks < 200L) { if (TimeUtil.AsyncNetTicks(asyncData.RequestTicks, asyncData.ServerTicks)) { LogManager.WriteLog(LogTypes.Ignore, string.Format("时间漂移#local={0},server={1}", asyncData.RequestTicks, asyncData.ServerTicks), null, true); } } AsyncDataItem[] items = asyncData.ItemList; if (items != null && items.Length > 0) { this.ExecuteEventCallBackAsync(items); } } } } catch (Exception ex) { this.ResetKuaFuService(); } }
private HuanYingSiYuanFuBenData GetKuaFuFuBenData(int gameId) { HuanYingSiYuanFuBenData huanYingSiYuanFuBenData = null; if (huanYingSiYuanFuBenData == null) { IKuaFuService kuaFuService = GetKuaFuService(); if (null != kuaFuService) { try { huanYingSiYuanFuBenData = (HuanYingSiYuanFuBenData)kuaFuService.GetFuBenData(gameId); } catch (System.Exception ex) { huanYingSiYuanFuBenData = null; } } } return(huanYingSiYuanFuBenData); }
/// <summary> /// 从服务器获取 /// </summary> /// <param name="roleId"></param> /// <returns></returns> public int GetRoleKuaFuFuBenRoleCount(int roleId) { int roleCount = 0; try { IKuaFuService kuaFuService = GetKuaFuService(); if (null != kuaFuService) { object result = kuaFuService.GetRoleExtendData(ClientInfo.ServerId, roleId, (int)KuaFuRoleExtendDataTypes.GameFuBenRoleCount); if (null != result) { roleCount = (int)result; } } } catch (System.Exception ex) { LogManager.WriteExceptionUseCache(ex.ToString()); } return(roleCount); }
public int UseGiftCode(string ptid, string uid, string rid, string channel, string codeno, string appid, int zoneid, ref string giftid) { try { IKuaFuService kuaFuService = this.GetKuaFuService(false); if (null != kuaFuService) { try { return(kuaFuService.UseGiftCode(ptid, uid, rid, channel, codeno, appid, zoneid, ref giftid)); } catch (Exception ex) { this.ResetKuaFuService(); } } } catch (Exception ex) { LogManager.WriteExceptionUseCache(ex.ToString()); } return(-11000); }
private IKuaFuService GetKuaFuService(bool noWait = false) { IKuaFuService kuaFuService = null; int clientId = -1; try { lock (Mutex) { if (string.IsNullOrEmpty(RemoteServiceUri)) { return(null); } if (null == KuaFuService && noWait) { return(null); } } lock (RemotingMutex) { if (KuaFuService == null) { kuaFuService = (IKuaFuService)Activator.GetObject(typeof(IKuaFuService), RemoteServiceUri); if (null == kuaFuService) { return(null); } } else { kuaFuService = KuaFuService; } //KuaFuClientContext clientContext = CallContext.GetData("KuaFuClientContext") as KuaFuClientContext; //if (null == clientContext) //{ // CallContext.SetData("KuaFuClientContext", new KuaFuClientContext() { ServerId = ClientInfo.ServerId, ClientId = ClientInfo.ClientId }); //} clientId = kuaFuService.InitializeClient(this, ClientInfo); if (null != kuaFuService && (clientId != ClientInfo.ClientId || KuaFuService != kuaFuService)) { lock (Mutex) { KuaFuService = kuaFuService; ClientInfo.ClientId = clientId; return(kuaFuService); } } return(KuaFuService); } } catch (System.Exception ex) { ResetKuaFuService(); LogManager.WriteExceptionUseCache(ex.ToString()); } return(null); }
/// <summary> /// 匹配报名 /// </summary> /// <param name="userId"></param> /// <param name="roleId"></param> /// <param name="zoneId"></param> /// <param name="gameType"></param> /// <param name="groupIndex"></param> /// <returns></returns> public int HuanYingSiYuanSignUp(string userId, int roleId, int zoneId, int gameType, int groupIndex, int zhanDouLi) { int result; if (string.IsNullOrEmpty(userId) || roleId <= 0) { return(StdErrorCode.Error_Not_Exist); } userId = userId.ToUpper(); int count = Interlocked.Increment(ref CurrentRequestCount); try { if (count < MaxRequestCount) { lock (Mutex) { KuaFuRoleData kuaFuRoleData; if (RoleId2RoleDataDict.TryGetValue(roleId, out kuaFuRoleData)) { //如果服务器ID不同,表明是跨服登录角色,不应该在此报名 if (kuaFuRoleData.ServerId != ClientInfo.ServerId) { return(StdErrorCode.Error_Operation_Faild); } } } IKuaFuService kuaFuService = GetKuaFuService(); if (null != kuaFuService) { try { HuanYingSiYuanGameData huanYingSiYuanGameData = new HuanYingSiYuanGameData() { ZhanDouLi = zhanDouLi }; result = kuaFuService.RoleSignUp(ClientInfo.ServerId, userId, zoneId, roleId, gameType, groupIndex, huanYingSiYuanGameData); } catch (System.Exception ex) { ResetKuaFuService(); } } else { return(StdErrorCode.Error_Server_Not_Registed); } } } catch (System.Exception ex) { LogManager.WriteExceptionUseCache(ex.ToString()); } finally { Interlocked.Decrement(ref CurrentRequestCount); } return(StdErrorCode.Error_Success); }