private void ApplyUsersAddedEvent(InternalSocialEvent socialEvent, bool isFreshEvent) { List <XboxSocialUser> usersAdded = new List <XboxSocialUser>(); if (socialEvent.UsersAffected == null) { Debug.WriteLine("Unable to apply UsersAdded event because we only have userIds."); return; } foreach (XboxSocialUser socialUser in socialEvent.UsersAffected) { if (this.userBuffer.Inactive.TryAdd(socialUser)) { usersAdded.Add(socialUser); } } if (usersAdded.Count > 0) { this.userBuffer.AddUsers(usersAdded); if (isFreshEvent) { this.internalEventQueue.Enqueue(InternalSocialEventType.UsersAdded, usersAdded); } } }
private void ApplyUsersChangeEvent(InternalSocialEvent socialEvent, bool isFreshEvent) { List <XboxSocialUser> usersToAdd = new List <XboxSocialUser>(); List <XboxSocialUser> usersToChange = new List <XboxSocialUser>(); foreach (XboxSocialUser user in socialEvent.UsersAffected) { if (this.userBuffer.Inactive.SocialUserGraph.ContainsValue(user)) { usersToChange.Add(user); } else { usersToAdd.Add(user); } } if (usersToAdd.Count > 0) { this.userBuffer.AddUsers(usersToAdd); if (isFreshEvent) { this.internalEventQueue.Enqueue(InternalSocialEventType.UsersAdded, usersToAdd); } } if (usersToChange.Count > 0 && isFreshEvent) { this.internalEventQueue.Enqueue(InternalSocialEventType.ProfilesChanged, usersToChange); } }
public void Enqueue(InternalSocialEvent socialEvent) { lock (((global::System.Collections.ICollection) this.eventQueue).SyncRoot) { this.eventQueue.Enqueue(socialEvent); } }
private void ApplyUsersRemovedEvent(InternalSocialEvent socialEvent, UserBuffer inactiveBuffer, bool isFreshEvent) { this.userBuffer.Inactive.Enqueue(socialEvent); foreach (XboxSocialUser user in socialEvent.UsersAffected) { } }
private void ApplyPresenceChangedEvent(InternalSocialEvent socialEvent, UserBuffer inactiveBuffer, bool isFreshEvent) { List <XboxSocialUser> usersToAddList = new List <XboxSocialUser>(); foreach (XboxSocialUser user in socialEvent.UsersAffected) { IList <SocialManagerPresenceTitleRecord> presenceDetails = user.PresenceDetails; UserPresenceState presenceState = user.PresenceState; var xuid = Convert.ToUInt64(user.XboxUserId); var eventUser = this.userBuffer.Inactive.SocialUserGraph[xuid]; if (eventUser != null) { if ((eventUser.PresenceState != presenceState) || (eventUser.PresenceDetails != null && presenceDetails != null && eventUser.PresenceDetails.Count > 0 && presenceDetails.Count > 0 && !eventUser.PresenceDetails.All(record => presenceDetails.Contains(record)))) { eventUser.PresenceDetails = presenceDetails; eventUser.PresenceState = presenceState; usersToAddList.Add(eventUser); } } } if (usersToAddList.Count > 0 && isFreshEvent) { this.internalEventQueue.Enqueue(InternalSocialEventType.PresenceChanged, usersToAddList); } }
public Task RemoveUsers(IList <XboxSocialUser> users) { InternalSocialEvent socialEvent = new InternalSocialEvent(InternalSocialEventType.UsersRemoved, users); this.internalEventQueue.Enqueue(socialEvent); return(socialEvent.Task); }
public bool TryDequeue(out InternalSocialEvent internalEvent) { lock (((global::System.Collections.ICollection) this.eventQueue).SyncRoot) { internalEvent = this.eventQueue.Count > 0 ? this.eventQueue.Dequeue() : null; return(internalEvent != null); } }
public Task AddUsers(IList <ulong> users) { InternalSocialEvent socialEvent = new InternalSocialEvent(InternalSocialEventType.UsersAdded, users); this.internalEventQueue.Enqueue(socialEvent); return(socialEvent.Task); }
public void Enqueue(InternalSocialEvent internalEvent, XboxLiveUser user) { if (internalEvent == null) { throw new ArgumentNullException("internalEvent"); } if (internalEvent.Type == InternalSocialEventType.Unknown) { throw new ArgumentException("Unable to handle Unknown event type.", "internalEvent"); } SocialEventType eventType; switch (internalEvent.Type) { case InternalSocialEventType.UsersAdded: eventType = SocialEventType.UsersAddedToSocialGraph; break; case InternalSocialEventType.UsersRemoved: eventType = SocialEventType.UsersRemovedFromSocialGraph; break; case InternalSocialEventType.PresenceChanged: case InternalSocialEventType.DevicePresenceChanged: case InternalSocialEventType.TitlePresenceChanged: eventType = SocialEventType.PresenceChanged; break; case InternalSocialEventType.ProfilesChanged: eventType = SocialEventType.ProfilesChanged; break; case InternalSocialEventType.SocialRelationshipsChanged: eventType = SocialEventType.SocialRelationshipsChanged; break; case InternalSocialEventType.Unknown: case InternalSocialEventType.UsersChanged: // These events are not converted into public events. return; default: throw new ArgumentOutOfRangeException("internalEvent", internalEvent.Type, null); } SocialEvent evt = new SocialEvent(eventType, user, internalEvent.UserIdsAffected); this.events.Enqueue(evt); this.State = EventState.ReadyToRead; }
public Task Enqueue(InternalSocialEventType socialEventType, List <XboxSocialUser> userList) { var numGroupsofUsers = userList.Count / MaxUsersAffectedPerEvent + 1; List <Task> eventTasks = new List <Task>(); for (int i = 0; i < numGroupsofUsers; ++i) { var evt = new InternalSocialEvent(socialEventType, userList.GetRange(i * numGroupsofUsers, numGroupsofUsers)); this.Enqueue(evt); eventTasks.Add(evt.Task); } return(Task.WhenAll(eventTasks)); }
private void ApplyTitlePresenceChangedEvent(InternalSocialEvent socialEvent, UserBuffer inactiveBuffer, bool isFreshEvent) { var titlePresenceChanged = socialEvent.TitlePresenceArgs; var xuid = Convert.ToUInt64(titlePresenceChanged.XboxUserId); var eventUser = inactiveBuffer.SocialUserGraph[xuid]; if (eventUser != null) { if (titlePresenceChanged.TitleState == TitlePresenceState.Ended) { var titleRecord = eventUser.PresenceDetails.FirstOrDefault(r => r.TitleId == titlePresenceChanged.TitleId); eventUser.PresenceDetails.Remove(titleRecord); } } }
private void ApplyUsersRemovedEvent(InternalSocialEvent socialEvent, bool isFreshEvent) { List <XboxSocialUser> usersToRemove = new List <XboxSocialUser>(); foreach (XboxSocialUser user in socialEvent.UsersAffected) { if (this.userBuffer.Inactive.SocialUserGraph.ContainsValue(user)) { usersToRemove.Add(user); } } if (usersToRemove.Count > 0) { this.userBuffer.RemoveUsers(usersToRemove); if (isFreshEvent) { this.internalEventQueue.Enqueue(InternalSocialEventType.UsersRemoved, usersToRemove); } } }
public void Enqueue(InternalSocialEvent internalEvent) { this.EventQueue.Enqueue(internalEvent); }
public void AddEvent(InternalSocialEvent internalSocialEvent) { this.Active.Enqueue(internalSocialEvent); }
private void ApplyPresenceChangedEvent(InternalSocialEvent socialEvent, UserBuffer inactiveBuffer, bool isFreshEvent) { throw new NotImplementedException(); }
private void ApplyEvent(InternalSocialEvent internalEvent, bool isFreshEvent) { UserBuffer inactiveBuffer = this.userBuffer.Inactive; switch (internalEvent.Type) { case InternalSocialEventType.UsersAdded: { this.ApplyUsersAddedEvent(internalEvent, isFreshEvent); break; } case InternalSocialEventType.UsersChanged: { this.ApplyUsersChangeEvent(internalEvent, isFreshEvent); break; } case InternalSocialEventType.UsersRemoved: { this.ApplyUsersRemovedEvent(internalEvent, inactiveBuffer, isFreshEvent); break; } case InternalSocialEventType.DevicePresenceChanged: { this.ApplyDevicePresenceChangedEvent(internalEvent, inactiveBuffer, isFreshEvent); break; } case InternalSocialEventType.TitlePresenceChanged: { this.ApplyTitlePresenceChangedEvent(internalEvent, inactiveBuffer, isFreshEvent); break; } case InternalSocialEventType.PresenceChanged: { this.ApplyPresenceChangedEvent(internalEvent, inactiveBuffer, isFreshEvent); break; } case InternalSocialEventType.SocialRelationshipsChanged: case InternalSocialEventType.ProfilesChanged: { foreach (var affectedUser in internalEvent.UsersAffected) { inactiveBuffer.SocialUserGraph[affectedUser.XboxUserId] = affectedUser; } break; } default: throw new ArgumentOutOfRangeException("internalEvent", internalEvent.Type, "Unknown event type."); } if (isFreshEvent) { this.eventQueue.Enqueue(internalEvent, this.localUser); this.userBuffer.AddEvent(internalEvent); } }
private void ApplyDevicePresenceChangedEvent(InternalSocialEvent socialEvent, bool isFreshEvent) { throw new NotImplementedException(); }
public void Enqueue(InternalSocialEventType socialEventType, List <ulong> userList) { InternalSocialEvent internalEvent = new InternalSocialEvent(socialEventType, userList); this.Enqueue(internalEvent); }