private async Task <string> OnHandleServerAccountQuery(JObject obj) { try { var account_id = obj["account_id"].ToString(); if (!string.IsNullOrEmpty(account_id)) { //角色列表// List <RoleIDSnap> roleList = new List <RoleIDSnap>(); using (var accountRoleSnapSave = new MappingReference <AccountRoleSnap>(RPGServerPersistenceManager.TYPE_ACCOUNT_ROLE_SNAP_DATA, account_id, this)) { var accountRoleSnap = await accountRoleSnapSave.LoadOrCreateDataAsync(() => new AccountRoleSnap()); foreach (var item in accountRoleSnap.roleIDMap) { roleList.Add(item.Value); } } return(CustomResult(true, JsonConvert.SerializeObject(roleList))); } else { return(CustomResult(false, null, "role_name_not_exist")); } } catch (Exception ex) { log.Error(ex); return(CustomResult(false, null, "page_gmt_command_unknown_error")); } }
protected override async Task OnStartAsync() { this.accountSave = new MappingReference <AccountData>(RPGServerPersistenceManager.TYPE_ACCOUNT_DATA, accountID, this); this.queryRoleSnap = new QueryMappingReference <RoleSnap>(RPGServerPersistenceManager.TYPE_ROLE_SNAP_DATA, this); this.accountRoleSnapSave = new MappingReference <AccountRoleSnap>(RPGServerPersistenceManager.TYPE_ACCOUNT_ROLE_SNAP_DATA, accountID, this); this.queryRoleDataStatusSnap = new QueryMappingReference <RoleDataStatusSnap>( RPGServerPersistenceManager.TYPE_ROLE_DATA_STATUS_SNAP_DATA, this); this.Provider.AutoDispose(accountSave); this.Provider.AutoDispose(queryRoleSnap); this.Provider.AutoDispose(accountRoleSnapSave); this.Provider.AutoDispose(queryRoleDataStatusSnap); this.heartbeat_timer = base.Provider.CreateTimer(CheckHeartbeat, this, TimeSpan.FromSeconds(TimerConfig.timer_sec_SessionKeepTimeout / 2), TimeSpan.FromSeconds(TimerConfig.timer_sec_SessionKeepTimeout / 2)); var data = await this.accountSave.LoadDataAsync(); var roleSnap = await this.accountRoleSnapSave.LoadDataAsync(); }
public virtual async Task DeleteRoleDataAsync(string c2s_role_uuid, ITaskExecutor svc) { var snapMapping = new MappingReference <RoleSnap>(TYPE_ROLE_SNAP_DATA, c2s_role_uuid, svc); var roleSnap = await snapMapping.LoadDataAsync(); // TODO }
/// <summary> /// 创建角色,由Session.Roled调用ORM. /// </summary> /// <typeparam name="T"></typeparam> /// <param name="data"></param> /// <returns></returns> public virtual async Task <RoleSnap> CreateRoleDataAsync(ServerRoleData data, ITaskExecutor svc) { var roleMapping = new MappingReference <ServerRoleData>(TYPE_ROLE_DATA, data.uuid, svc); await roleMapping.SaveDataAsync(data); var snapData = InitRoleSnap(data, new RoleSnap()); // Snap数据映射 var snapMapping = new MappingReference <RoleSnap>(TYPE_ROLE_SNAP_DATA, data.uuid, svc); await snapMapping.SaveDataAsync(snapData); return(snapData); }
protected override void OnDisposed() { this.accountSave.Dispose(); this.accountRoleSnapSave.Dispose(); this.queryRoleSnap.Dispose(); this.queryRoleDataStatusSnap.Dispose(); this.session = null; this.enter = null; this.remote_logic_service = null; this.remote_area_service = null; this.enter_game = null; this.heartbeat_timer = null; this.sessionToken = null; this.accountSave = null; this.queryRoleSnap = null; this.queryRoleDataStatusSnap = null; this.accountRoleSnapSave = null; }
public virtual async Task <AccountData> GetOrCreateAccountDataAsync(MappingReference <AccountData> saveAcc, string accountName, string accountToken) { if (await saveAcc.EnterLockAsync(out var token)) { try { var accountData = await saveAcc.LoadOrCreateDataAsync(() => { var ret = new AccountData(); ret.uuid = accountName; ret.token = accountToken; return(ret); }); return(accountData); } finally { await saveAcc.ExitLockAsync(token); } } return(null); }