Ejemplo 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();
            });
        }
Ejemplo 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);
     }
 }
Ejemplo 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);
        }