Esempio n. 1
0
 /// <summary>
 /// generate a null UID.
 /// </summary>
 /// <returns></returns>
 public static UID GenerateNullUID()
 {
     if (_null is null)
     {
         _null = new UID();
     }
     return(_null);
 }
Esempio n. 2
0
        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));;
            //---------------------------------------------
        }
Esempio n. 3
0
        public static UID[] GenerateNullUIDs(int _count)
        {
            var _value = new UID[_count];

            for (int i = 0; i < _value.Length; i++)
            {
                _value[i] = GenerateNullUID();
            }
            return(_value);
        }
Esempio n. 4
0
        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);
        }
Esempio n. 5
0
        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);
        }
Esempio n. 6
0
        /// <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);
        }
Esempio n. 7
0
        //-------------------------------------------------
        #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);
        }
Esempio n. 8
0
        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));

            //---------------------------------------------
        }
Esempio n. 9
0
 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);
     }
 }
Esempio n. 10
0
        //-------------------------------------------------
        #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));

            //---------------------------------------------
        }
Esempio n. 11
0
 public static async Task <bool> DeletePlayer(UID _uid_)
 {
     if (_uid_ == null || _uid_.IsNullUID)
     {
         return(true);
     }
     if (!await PlayerInfo.DeletePlayerInfo(_uid_))
     {
         return(false);
     }
     if (!await Me.DeleteMe(_uid_))
     {
         return(false);
     }
     if (!await Troop.DeleteTroops(_uid_))
     {
         return(false);
     }
     if (!await MagicalTroop.DeleteMagicalTroops(_uid_))
     {
         return(false);
     }
     if (!await PlayerResources.DeletePlayerResources(_uid_))
     {
         return(false);
     }
     if (!await HeroManager.DeletePlayerHeroes(_uid_))
     {
         return(false);
     }
     if (!await DeleteUID(_uid_))
     {
         return(false);
     }
     return(true);
 }