Esempio n. 1
0
        /// <summary>
        /// Sends a request to server, retrieves all profile values, and applies them to a provided
        /// profile
        /// </summary>
        public void FillProfileValues(ObservableServerProfile profile, SuccessCallback successCallback, ErrorCallback errorCallback)
        {
            if (!Client.IsConnected)
            {
                errorCallback.Invoke("Not connected");
                return;
            }

            Client.SendMessage((ushort)OpCodes.ServerProfileRequest, profile.Username, (status, response) =>
            {
                if (status != ResponseStatus.Success)
                {
                    errorCallback.Invoke(response.AsString("Unknown error"));
                    return;
                }

                // Use the bytes received, to replicate the profile
                profile.FromBytes(response.AsBytes());

                profile.ClearUpdates();

                _profiles[profile.Username] = profile;

                profile.ModifiedInServer += serverProfile =>
                {
                    OnProfileModified(profile);
                };

                profile.Disposed += OnProfileDisposed;

                successCallback.Invoke();
            });
        }
Esempio n. 2
0
 /// <summary>
 /// Get profile info from database
 /// </summary>
 /// <param name="profile"></param>
 public async Task RestoreProfileAsync(ObservableServerProfile profile)
 {
     try
     {
         var data = await FindOrCreateData(profile);
         profile.FromBytes(data.Data);
     }
     catch (Exception e)
     {
         UnityEngine.Debug.LogError(e);
     }
 }
Esempio n. 3
0
        /// <summary>
        /// Get profile info from database
        /// </summary>
        /// <param name="profile"></param>
        public void RestoreProfile(ObservableServerProfile profile)
        {
            var data = FindOrCreateData(profile);

            profile.FromBytes(data.Data);
        }