public XboxSocialUserGroup CreateSocialUserGroupFromFilters(XboxLiveUser user, PresenceFilter presenceFilter, RelationshipFilter relationshipFilter) { if (user == null) { throw new ArgumentNullException("user"); } SocialGraph userGraph; if (!this.userGraphs.TryGetValue(user, out userGraph)) { throw new ArgumentException("You must add a local user before you can create a social group for them.", "user"); } XboxSocialUserGroup group = new XboxSocialUserGroup(user, presenceFilter, relationshipFilter, XboxLiveAppConfiguration.Instance.TitleId); if (userGraph.IsInitialized) { group.InitializeGroup(userGraph.ActiveUsers); } this.AddUserGroup(user, group); this.eventQueue.Enqueue(new SocialEvent(SocialEventType.SocialUserGroupLoaded, user, null, group)); return(group); }
public XboxSocialUserGroup CreateSocialUserGroupFromFilters(XboxLiveUser user, PresenceFilter presenceFilter, RelationshipFilter relationshipFilter) { if (user == null) { throw new ArgumentNullException("user"); } // Allocates memory for returned objects IntPtr cGroupPtr = Marshal.AllocHGlobal(Marshal.SizeOf <IntPtr>()); IntPtr cErrMessage = Marshal.AllocHGlobal(Marshal.SizeOf <IntPtr>()); // Invokes the c method XSAPI_RESULT errCode = SocialManagerCreateSocialUserGroupFromFilters(user.Impl.XboxLiveUserPtr, presenceFilter, relationshipFilter, cGroupPtr, cErrMessage); // Handles error string errMessage = Marshal.PtrToStringAnsi(Marshal.ReadIntPtr(cErrMessage)); Marshal.FreeHGlobal(cErrMessage); if (errCode != XSAPI_RESULT.XSAPI_RESULT_OK) { // todo do something } // Handles returned objects XboxSocialUserGroup socialUserGroup = new XboxSocialUserGroup(Marshal.ReadIntPtr(cGroupPtr)); Marshal.FreeHGlobal(cGroupPtr); m_groups.Add(socialUserGroup); return(socialUserGroup); }
public XboxSocialUserGroup CreateSocialUserGroupFromFilters(XboxLiveUser user, PresenceFilter presenceFilter, RelationshipFilter relationshipFilter) { Dictionary <string, XboxSocialUser> users = Enumerable.Range(0, 5) .Select(id => { var groupUser = CreateUser(); switch (presenceFilter) { case PresenceFilter.AllOnline: case PresenceFilter.TitleOnline: InitUserForOnlinePresence(ref groupUser); break; case PresenceFilter.AllOffline: case PresenceFilter.TitleOffline: InitUserForOfflinePresence(ref groupUser); break; case PresenceFilter.AllTitle: case PresenceFilter.All: if (id % 2 == 0) { InitUserForOnlinePresence(ref groupUser); } else { InitUserForOfflinePresence(ref groupUser); } break; } switch (relationshipFilter) { case RelationshipFilter.Friends: groupUser.IsFollowedByCaller = true; break; case RelationshipFilter.Favorite: groupUser.IsFollowedByCaller = true; groupUser.IsFavorite = true; break; } return(groupUser); }).ToDictionary(u => u.XboxUserId); XboxSocialUserGroup group = new XboxSocialUserGroup(user, SocialUserGroupType.Filter, presenceFilter, relationshipFilter, users); mEvents.Add(new SocialEvent(SocialEventType.SocialUserGroupLoaded, user, null, group)); return(group); }
public void TestPresenceFilter() { PresenceFilter v1 = new PresenceFilter("foo"); PresenceFilter v2 = (PresenceFilter)CloneObject(v1); Assert.AreEqual(v1.Name, v2.Name); }
private static extern XSAPI_RESULT SocialManagerCreateSocialUserGroupFromFilters(IntPtr user, PresenceFilter presenceDetailFilter, RelationshipFilter filter, IntPtr returnGroup, IntPtr errMessage);
public XboxSocialUserGroup CreateSocialUserGroupFromFilters(XboxLiveUser user, PresenceFilter presenceFilter, RelationshipFilter relationshipFilter) { if (user == null) { throw new ArgumentNullException("user"); } IntPtr cGroupPtr; IntPtr cErrMessage; // Invokes the c method XSAPI_RESULT errCode = SocialManagerCreateSocialUserGroupFromFilters(user.Impl.XboxLiveUserPtr, presenceFilter, relationshipFilter, out cGroupPtr, out cErrMessage); if (errCode != XSAPI_RESULT.XSAPI_RESULT_OK) { throw new XboxException(errCode, cErrMessage); } // Handles returned objects XboxSocialUserGroup socialUserGroup = new XboxSocialUserGroup(cGroupPtr); m_groups.Add(socialUserGroup); return(socialUserGroup); }
public XboxSocialUserGroup CreateSocialUserGroupFromFilters(XboxLiveUser user, PresenceFilter presenceFilter, RelationshipFilter relationshipFilter) { var group = new XboxSocialUserGroup(user, presenceFilter, relationshipFilter, XboxLiveAppConfiguration.Instance.TitleId); var users = Enumerable.Range(0, 5) .Select(id => { var groupUser = CreateUser(); switch (presenceFilter) { case PresenceFilter.AllOnline: case PresenceFilter.TitleOnline: InitUserForOnlinePresence(ref groupUser); break; case PresenceFilter.AllOffline: case PresenceFilter.TitleOffline: InitUserForOfflinePresence(ref groupUser); break; case PresenceFilter.AllTitle: case PresenceFilter.All: if (id % 2 == 0) { InitUserForOnlinePresence(ref groupUser); } else { InitUserForOfflinePresence(ref groupUser); } break; } switch (relationshipFilter) { case RelationshipFilter.Friends: groupUser.IsFollowedByCaller = true; break; case RelationshipFilter.Favorite: groupUser.IsFollowedByCaller = true; groupUser.IsFavorite = true; break; } return(groupUser); }).ToDictionary(u => u.XboxUserId); group.InitializeGroup(users.Values); group.UpdateView(users, new List <SocialEvent>()); this.events.Add(new SocialEvent(SocialEventType.SocialUserGroupLoaded, user, null, group)); return(group); }
public XboxSocialUserGroup CreateSocialUserGroupFromFilters(XboxLiveUser user, PresenceFilter presenceFilter, RelationshipFilter relationshipFilter, uint titleId) { if (user == null) { throw new ArgumentNullException("user"); } SocialGraph userGraph; if (!this.userGraphs.TryGetValue(user, out userGraph)) { throw new ArgumentException("You must add a local user before you can create a social group for them.", "user"); } XboxSocialUserGroup group = new XboxSocialUserGroup(user, presenceFilter, relationshipFilter, userGraph.TitleId); if (userGraph.IsInitialized) { group.InitializeGroup(userGraph.ActiveUsers); } this.AddUserGroup(user, group); return(group); }
// Used for mock services internal XboxSocialUserGroup(XboxLiveUser localUser, SocialUserGroupType groupType = SocialUserGroupType.Filter, PresenceFilter presence = PresenceFilter.Unknown, RelationshipFilter relationship = RelationshipFilter.Friends, Dictionary <string, XboxSocialUser> users = null, List <string> trackedUsers = null) { LocalUser = localUser; SocialUserGroupType = groupType; PresenceFilterOfGroup = presence; RelationshipFilterOfGroup = relationship; m_users = users == null ? new Dictionary <string, XboxSocialUser>() : users; m_trackedUsers = trackedUsers == null ? new List <string>() : trackedUsers; }
public XboxSocialUserGroup CreateSocialUserGroupFromFilters(XboxLiveUser user, PresenceFilter presenceFilter, RelationshipFilter relationshipFilter, uint titleId) { var group = new XboxSocialUserGroup(user, presenceFilter, relationshipFilter, titleId); var users = Enumerable.Range(0, 5) .Select(id => { var groupUser = CreateUser(); switch (presenceFilter) { case PresenceFilter.TitleOnline: groupUser.PresenceState = UserPresenceState.Online; groupUser.PresenceDetails = new List <SocialManagerPresenceTitleRecord> { new SocialManagerPresenceTitleRecord { TitleId = titleId, IsTitleActive = false, } }; break; case PresenceFilter.TitleOffline: groupUser.PresenceState = UserPresenceState.Offline; groupUser.TitleHistory = new TitleHistory { HasUserPlayed = true, LastTimeUserPlayed = DateTime.UtcNow.AddDays(-1), }; break; case PresenceFilter.AllOnline: groupUser.PresenceState = UserPresenceState.Online; break; case PresenceFilter.AllOffline: groupUser.PresenceState = UserPresenceState.Offline; break; case PresenceFilter.AllTitle: break; } switch (relationshipFilter) { case RelationshipFilter.Friends: groupUser.IsFollowedByCaller = true; break; case RelationshipFilter.Favorite: groupUser.IsFollowedByCaller = true; groupUser.IsFavorite = true; break; } return(groupUser); }).ToDictionary(u => u.XboxUserId); group.InitializeGroup(users.Values); group.UpdateView(users, new List <SocialEvent>()); this.events.Add(new SocialEvent(SocialEventType.SocialUserGroupLoaded, user, null, group)); return(group); }