public static async Task <bool> DeletePlayerInfo(UID _uid_) { bool _r1, _r2; //--------------------------------------------- var _target = _uid_.GetValue() + PI_Server_LOC; var _s = ThereIsServer.ServersInfo.ServerManager.Get_PlayerInfo_Server(_uid_.TheSocket); var existing = await ThereIsServer.Actions.GetAllContentsByRef(_s, _target); //--------------------------------------------- if (existing.DoesNotExist) { _r1 = true; } else { if (existing.IsDeadCallBack || ThereIsServer.ServerSettings.HasConnectionClosed) { NoInternetConnectionSandBox.PrepareConnectionClosedSandBox(); return(false); } //--------------------------------------------- var _req_ = new DataBaseDeleteRequest(MESSAGE, existing.Sha.GetStrong()); _r1 = await ThereIsServer.Actions.DeleteData(_s, _target, _req_); //--------------------------------------------- } //--------------------------------------------- _target = _uid_.GetValue() + ThereIsServer.ServersInfo.EndCheckingFileName; _s = ThereIsServer.ServersInfo.ServerManager.Get_Login_Server(_uid_.TheSocket); existing = await ThereIsServer.Actions.GetAllContentsByRef(_s, _target); //--------------------------------------------- if (existing.DoesNotExist) { _r2 = true; return(_r1 && _r2); } if (existing.IsDeadCallBack || ThereIsServer.ServerSettings.HasConnectionClosed) { NoInternetConnectionSandBox.PrepareConnectionClosedSandBox(); return(false); } //--------------------------------------------- var _req = new DataBaseDeleteRequest(Player.LI_MESSAGE, existing.Sha.GetStrong()); _r2 = await ThereIsServer.Actions.DeleteData(_s, _target, _req); //--------------------------------------------- return(_r1 && _r2); }
/// <summary> /// use this method just for generating a new UID. /// </summary> /// <param name="_username_"></param> /// <param name="_socket_"></param> /// <returns></returns> public static async Task <UID> GenerateUID(StrongString _username_, IPlayerSocket _socket_) { int myIndex = Randomic.GetRandom(MIN_SERVER_INDEX, MAX_SERVER_INDEX); var _s = ThereIsServer.ServersInfo.ServerManager.Get_UID_Generation_Server(myIndex); StrongString _target = ServerManager.Generation_Location_Name; UID uid; ulong _value; for (var i = 0; ; i++) { var existing = await ThereIsServer.Actions.GetAllContentsByRef(_s, _target); if (existing.IsDeadCallBack || ThereIsServer.ServerSettings.HasConnectionClosed) { NoInternetConnectionSandBox.PrepareConnectionClosedSandBox(); return(null); } _value = existing.Decode().ToUInt64(); _value++; var _req = new DataBaseUpdateRequest(UID_MESSAGE, _value.ToString(UID_FORMAT), existing.Sha.GetStrong()); var _result = await ThereIsServer.Actions.UpdateDataOnce(_s, _target, _req); if (_result.IsDeadCallBack) { continue; } if (ThereIsServer.ServerSettings.HasConnectionClosed || i >= MAX_TRY) { return(null); } break; } //---------------------- uid = new UID(myIndex, _value, _socket_, _username_); _s = ThereIsServer.ServersInfo.ServerManager.Get_UID_Server(uid); _target = uid.GetValue() + UID_Lcation_Name; var _creation = new DataBaseCreation(UID_MESSAGE, QString.Parse(uid.GetForServer())); await ThereIsServer.Actions.CreateData(_s, _target, _creation); //---------------------- _s = ThereIsServer.ServersInfo.ServerManager.Get_UID_Server(_username_); _target = _username_ + USERNAME_TO_UID; _creation = new DataBaseCreation(UID_MESSAGE, QString.Parse(uid.GetValue())); await ThereIsServer.Actions.CreateData(_s, _target, _creation); //---------------------- return(uid); }
public async Task <bool> CheckForExistence(UID _uid) { //--------------------------------------------- var _s = ThereIsServer.ServersInfo.ServerManager.Get_UID_Server(_uid); var _target = _uid.GetValue() + UID.UID_Lcation_Name; return(await ThereIsServer.Actions.Exists(_s, _target));; //--------------------------------------------- }
private static async Task <bool> DeleteUID(UID _uid_) { bool _r1, _r2; //--------------------------------------------- var _s = ThereIsServer.ServersInfo.ServerManager.Get_UID_Server(_uid_); var _target = _uid_.GetValue() + UID_Lcation_Name; var existing = await ThereIsServer.Actions.GetAllContentsByRef(_s, _target); //--------------------------------------------- if (existing.DoesNotExist) { _r1 = true; } else { if (existing.IsDeadCallBack || ThereIsServer.ServerSettings.HasConnectionClosed) { NoInternetConnectionSandBox.PrepareConnectionClosedSandBox(); return(false); } //--------------------------------------------- var _req = new DataBaseDeleteRequest(UID_MESSAGE, existing.Sha.GetStrong()); _r1 = await ThereIsServer.Actions.DeleteData(_s, _target, _req); //--------------------------------------------- } //--------------------------------------------- _s = ThereIsServer.ServersInfo.ServerManager.Get_UID_Server(_uid_.PlayerUserName); _target = _uid_.PlayerUserName + USERNAME_TO_UID; existing = await ThereIsServer.Actions.GetAllContentsByRef(_s, _target); //--------------------------------------------- if (existing.DoesNotExist) { _r2 = true; } else { if (existing.IsDeadCallBack || ThereIsServer.ServerSettings.HasConnectionClosed) { NoInternetConnectionSandBox.PrepareConnectionClosedSandBox(); return(false); } //--------------------------------------------- var _req = new DataBaseDeleteRequest(UID_MESSAGE, existing.Sha.GetStrong()); _r2 = await ThereIsServer.Actions.DeleteData(_s, _target, _req); //--------------------------------------------- } return(_r1 && _r2); }
//------------------------------------------------- #region Online Methods Region public async Task <bool> ReloadPlayer() { //--------------------------------------------- var _s = ThereIsServer.ServersInfo.ServerManager.Get_Player_Server(Socket); var _target = UID.GetValue() + EndFileName_Player; var existing = await ThereIsServer.Actions.GetAllContentsByRef(_s, _target); //--------------------------------------------- if (existing.IsDeadCallBack || ThereIsServer.ServerSettings.HasConnectionClosed) { NoInternetConnectionSandBox.PrepareConnectionClosedSandBox(); return(false); } SetParams(existing.Decode()); return(true); }
public async Task <DataBaseDataChangedInfo> UpdatePlayer() { //--------------------------------------------- var _s = ThereIsServer.ServersInfo.ServerManager.Get_Player_Server(Socket); var _target = UID.GetValue() + EndFileName_Player; var existing = await ThereIsServer.Actions.GetAllContentsByRef(_s, _target); //--------------------------------------------- if (existing.IsDeadCallBack || ThereIsServer.ServerSettings.HasConnectionClosed) { NoInternetConnectionSandBox.PrepareConnectionClosedSandBox(); return(null); } //--------------------------------------------- var _req = new DataBaseUpdateRequest(PLAYER_MESSAGE, PlayerGetForServer(), existing.Sha.GetStrong()); return(await ThereIsServer.Actions.UpdateData(_s, _target, _req)); //--------------------------------------------- }
public async Task <DataBaseDataChangedInfo> UpdatePlayerInfo(DataBaseContent existing) { try { //----------------------------------------- var _target = UID.GetValue() + PI_Server_LOC; var _s = ThereIsServer.ServersInfo.ServerManager.Get_PlayerInfo_Server(Socket); //----------------------------------------- if (existing.IsDeadCallBack || ThereIsServer.ServerSettings.HasConnectionClosed) { NoInternetConnectionSandBox.PrepareConnectionClosedSandBox(); return(null); } var _req = new DataBaseUpdateRequest(MESSAGE, QString.Parse(PlayerInfoGetForServer()), existing.Sha); return(await ThereIsServer.Actions.UpdateData(_s, _target, _req)); } catch { return(null); } }
//------------------------------------------------- #region static Method's Region public static async Task <bool> DeletePlayer(UID _uid_) { //--------------------------------------------- var _s = ThereIsServer.ServersInfo.ServerManager.Get_Player_Server(_uid_.TheSocket); var _target = _uid_.GetValue() + EndFileName_Player; var existing = await ThereIsServer.Actions.GetAllContentsByRef(_s, _target); //--------------------------------------------- if (existing.DoesNotExist) { return(true); } if (existing.IsDeadCallBack || ThereIsServer.ServerSettings.HasConnectionClosed) { NoInternetConnectionSandBox.PrepareConnectionClosedSandBox(); return(false); } //--------------------------------------------- var _req = new DataBaseDeleteRequest(PLAYER_MESSAGE, existing.Sha.GetStrong()); return(await ThereIsServer.Actions.DeleteData(_s, _target, _req)); //--------------------------------------------- }