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 void SwapIfEmpty() { if (!this.Inactive.IsEmpty) { return; } UserBuffer swapBuffer = this.Active; this.Active = this.Inactive; this.Inactive = swapBuffer; }
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 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); } }