internal ChangeListType GetChanges(XboxSocialUser other) { ChangeListType changeType = ChangeListType.NoChange; if (!string.Equals(this.Gamertag, other.Gamertag, StringComparison.OrdinalIgnoreCase) || !string.Equals(this.Gamerscore, other.Gamerscore, StringComparison.OrdinalIgnoreCase) || !string.Equals(this.RealName, other.RealName, StringComparison.OrdinalIgnoreCase) || !string.Equals(this.DisplayName, other.DisplayName, StringComparison.OrdinalIgnoreCase) || !string.Equals(this.DisplayPicRaw, other.DisplayPicRaw, StringComparison.OrdinalIgnoreCase) || this.UseAvatar != other.UseAvatar || !Equals(this.PreferredColor, other.PreferredColor) || !Equals(this.TitleHistory, other.TitleHistory)) { changeType |= ChangeListType.ProfileChange; } if (this.IsFollowedByCaller != other.IsFollowedByCaller || this.IsFollowingCaller != other.IsFollowingCaller || this.IsFavorite != other.IsFavorite) { changeType |= ChangeListType.SocialRelationshipChange; } if (this.PresenceState != other.PresenceState || (this.PresenceDetails != null && other.PresenceDetails != null && this.PresenceDetails.All(record => other.PresenceDetails.Contains(record)))) { changeType |= ChangeListType.PresenceChange; } return(changeType); }
private void InitUserForOfflinePresence(ref XboxSocialUser groupUser) { groupUser.PresenceState = UserPresenceState.Offline; groupUser.TitleHistory = new TitleHistory { HasUserPlayed = true, LastTimeUserPlayed = DateTime.UtcNow.AddDays(-1), }; }
// todo For perf consider if we need an init method and a refresh method seperate internal void Refresh() { var cSocialUserGroup = Marshal.PtrToStructure <XBOX_SOCIAL_USER_GROUP>(m_socialUserGroupPtr); // Properties SocialUserGroupType = cSocialUserGroup.SocialUserGroupType; PresenceFilterOfGroup = cSocialUserGroup.PresenceFilterOfGroup; RelationshipFilterOfGroup = cSocialUserGroup.RelationshipFilterOfGroup; // Local User if (LocalUser == null) { var manager = (SocialManager)XboxLive.Instance.SocialManager; LocalUser = manager.GetUser(cSocialUserGroup.LocalUser); } LocalUser.Impl.UpdatePropertiesFromXboxLiveUserPtr(); // Users // todo: for perf consider not removing everthing, but updating certain things and deleting the rest m_users.Clear(); if (cSocialUserGroup.UsersCount > 0) { IntPtr[] cUsersArray = new IntPtr[cSocialUserGroup.UsersCount]; Marshal.Copy(cSocialUserGroup.Users, cUsersArray, 0, (int)cSocialUserGroup.UsersCount); for (int i = 0; i < cUsersArray.Count(); i++) { var socialUser = new XboxSocialUser(cUsersArray[i]); m_users[socialUser.XboxUserId] = socialUser; } } // Users Tracked // todo: for perf consider whether this list is static or dynamic m_trackedUsers.Clear(); if (cSocialUserGroup.UsersTrackedBySocialUserGroupCount > 0) { IntPtr[] cTrackedUsers = new IntPtr[cSocialUserGroup.UsersTrackedBySocialUserGroupCount]; Marshal.Copy(cSocialUserGroup.UsersTrackedBySocialUserGroup, cTrackedUsers, 0, (int)cSocialUserGroup.UsersTrackedBySocialUserGroupCount); for (int i = 0; i < cTrackedUsers.Count(); i++) { var cSocialUser = Marshal.PtrToStructure <SocialManager.XBOX_USER_ID_CONTAINER>(cTrackedUsers[i]); string xuid = MarshalingHelpers.Utf8ToString(cSocialUser.XboxUserId); m_trackedUsers.Add(xuid); } } }
private void InitUserForOnlinePresence(ref XboxSocialUser groupUser) { groupUser.PresenceState = UserPresenceState.Online; groupUser.PresenceDetails = new List <SocialManagerPresenceTitleRecord> { new SocialManagerPresenceTitleRecord { TitleId = XboxLiveAppConfiguration.Instance.TitleId, IsTitleActive = true, } }; }
public bool TryRemove(XboxSocialUser user) { lock (((global::System.Collections.ICollection) this.SocialUserGraph).SyncRoot) { if (this.SocialUserGraph.ContainsKey(user.XboxUserId)) { this.SocialUserGraph.Remove(user.XboxUserId); return(true); } return(false); } }
private void InitUserForOnlinePresence(ref XboxSocialUser groupUser) { List <SocialManagerPresenceTitleRecord> titles = new List <SocialManagerPresenceTitleRecord> { new SocialManagerPresenceTitleRecord { TitleId = XboxLiveAppConfiguration.SingletonInstance.TitleId, IsTitleActive = true, } }; groupUser.PresenceRecord = new SocialManagerPresenceRecord(UserPresenceState.Online, titles); }
public bool TryAdd(XboxSocialUser user) { lock (((global::System.Collections.ICollection) this.SocialUserGraph).SyncRoot) { XboxSocialUser existingUser; if (this.SocialUserGraph.TryGetValue(user.XboxUserId, out existingUser)) { return(false); } this.SocialUserGraph[user.XboxUserId] = user; return(true); } }