Beispiel #1
0
        /// <summary>
        /// Should restore all values of the given profile,
        /// or not change them, if there's no entry in the database
        /// </summary>
        /// <returns></returns>
        public void RestoreProfile(ObservableServerProfile profile, Action doneCallback)
        {
            var data = FindOrCreateData(profile);

            profile.FromBytes(data.Data);
            doneCallback.Invoke();
        }
Beispiel #2
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 callback,
                                      IClientSocket connection)
        {
            if (!connection.IsConnected)
            {
                callback.Invoke(false, "Not connected");
                return;
            }

            connection.SendMessage((short)MsfOpCodes.ServerProfileRequest, profile.Username, (status, response) => {
                if (status != ResponseStatus.Success)
                {
                    callback.Invoke(false, 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, connection); };

                profile.Disposed += OnProfileDisposed;

                callback.Invoke(true, null);
            });
        }
Beispiel #3
0
        /// <summary>
        /// Should restore all values of the given profile,
        /// or not change them, if there's no entry in the database
        /// </summary>
        /// <param name="profile"></param>
        /// <returns></returns>
        public void RestoreProfile(ObservableServerProfile profile)
        {
            var data = FindOrCreateData(profile);

            profile.FromBytes(data.Data);
        }