public SocialGraph(XboxLiveUser localUser, SocialManagerExtraDetailLevel detailLevel) { this.localUser = localUser; this.detailLevel = detailLevel; this.peopleHubService = new PeopleHubService(); }
private Task <List <XboxSocialUser> > GetSocialGraph(XboxLiveUser user, SocialManagerExtraDetailLevel decorations, string relationshipType, IList <string> xboxLiveUsers) { bool isBatch = xboxLiveUsers != null && xboxLiveUsers.Count > 0; string pathAndQuery = this.CreateSocialGraphSubpath(user.XboxUserId, decorations, relationshipType, isBatch); XboxLiveHttpRequest request = XboxLiveHttpRequest.Create( isBatch ? HttpMethod.Post : HttpMethod.Get, this.peopleHubEndpoint, pathAndQuery); request.ContractVersion = "1"; if (isBatch) { JObject postBody = new JObject(new JProperty("xuids", xboxLiveUsers)); request.RequestBody = postBody.ToString(Formatting.None); } request.XboxLiveAPI = XboxLiveAPIName.GetSocialGraph; request.CallerContext = "SocialManager"; return(request.GetResponseWithAuth(user) .ContinueWith(responseTask => { var response = responseTask.Result; JObject responseBody = JObject.Parse(response.ResponseBodyString); List <XboxSocialUser> users = responseBody["people"].ToObject <List <XboxSocialUser> >(); return users; })); }
public void AddLocalUser(XboxLiveUser user, SocialManagerExtraDetailLevel extraDetailLevel) { if (user == null) { throw new ArgumentNullException("user"); } // Allocates memory for returned objects IntPtr cErrMessage = Marshal.AllocHGlobal(Marshal.SizeOf <IntPtr>()); // Invokes the c method XSAPI_RESULT errCode = SocialManagerAddLocalUser(user.Impl.XboxLiveUserPtr, extraDetailLevel, cErrMessage); // Handles error string errMessage = Marshal.PtrToStringAnsi(Marshal.ReadIntPtr(cErrMessage)); Marshal.FreeHGlobal(cErrMessage); if (errCode != XSAPI_RESULT.XSAPI_RESULT_OK) { // todo do something } m_localUsers.Add(user); }
public Task AddLocalUser(XboxLiveUser user, SocialManagerExtraDetailLevel extraDetailLevel) { if (user == null) { throw new ArgumentNullException("user"); } if (this.userGraphs.ContainsKey(user)) { throw new XboxException("User already exists in graph."); } SocialGraph graph = new SocialGraph(user, extraDetailLevel); return(graph.Initialize().ContinueWith( initializeTask => { // Wait on the task to throw an exceptions. initializeTask.Wait(); lock (this.syncRoot) { this.userGraphs[user] = graph; this.localUsers.Add(user); this.eventQueue.Enqueue(new SocialEvent(SocialEventType.LocalUserAdded, user)); } })); }
public SocialGraph(XboxLiveUser localUser, SocialManagerExtraDetailLevel detailLevel) { this.localUser = localUser; this.detailLevel = detailLevel; this.peopleHubService = new PeopleHubService(); this.eventQueue = new EventQueue(this.localUser); this.internalEventQueue = new InternalEventQueue(); }
public SocialGraph(XboxLiveUser localUser, SocialManagerExtraDetailLevel detailLevel) { this.localUser = localUser; this.detailLevel = detailLevel; this.context = new XboxLiveContext(this.localUser); this.peopleHubService = new PeopleHubService(this.context.Settings, this.context.AppConfig); this.eventQueue = new EventQueue(this.localUser); this.internalEventQueue = new InternalEventQueue(); }
/// <summary> /// Get profile information for a user. /// </summary> /// <param name="user">The user to get profile information for.</param> /// <param name="decorations">The additional detail to include in the response</param> /// <returns>Social profile information for the user.</returns> public Task <XboxSocialUser> GetProfileInfo(XboxLiveUser user, SocialManagerExtraDetailLevel decorations) { string path = "/users/me/people/xuids(" + user.XboxUserId + ")"; path += "/decoration/"; if ((decorations | SocialManagerExtraDetailLevel.None) != SocialManagerExtraDetailLevel.None) { if (decorations.HasFlag(SocialManagerExtraDetailLevel.TitleHistory)) { path += "titlehistory(" + this.appConfig.TitleId + "),"; } if (decorations.HasFlag(SocialManagerExtraDetailLevel.PreferredColor)) { path += "preferredcolor,"; } } // We always ask for presence detail. path += "presenceDetail"; XboxLiveHttpRequest request = XboxLiveHttpRequest.Create( HttpMethod.Get, this.peopleHubEndpoint, path); request.ContractVersion = "1"; request.XboxLiveAPI = XboxLiveAPIName.GetProfileInfo; request.CallerContext = "SocialManager"; return(request.GetResponseWithAuth(user) .ContinueWith(responseTask => { if (responseTask.IsFaulted) { throw new XboxException("PeopleHub call failed with " + responseTask.Exception); } var response = responseTask.Result; if (response.HttpStatus != 200) { throw new XboxException("PeopleHub call failed with " + response.HttpStatus); } JObject responseBody = JObject.Parse(response.ResponseBodyString); List <XboxSocialUser> users = responseBody["people"].ToObject <List <XboxSocialUser> >(); return users[0]; })); }
public void AddLocalUser(XboxLiveUser user, SocialManagerExtraDetailLevel extraDetailLevel) { if (user == null) { throw new ArgumentNullException("user"); } IntPtr cErrMessage; // Invokes the c method XSAPI_RESULT errCode = SocialManagerAddLocalUser(user.Impl.XboxLiveUserPtr, extraDetailLevel, out cErrMessage); // Handles error if (errCode != XSAPI_RESULT.XSAPI_RESULT_OK) { throw new XboxException(errCode, cErrMessage); } m_localUsers[user.Impl.XboxLiveUserPtr] = user; }
private string CreateSocialGraphSubpath(string xboxUserId, SocialManagerExtraDetailLevel decorations, string relationshipType, bool isBatch) { StringBuilder path = new StringBuilder(); path.Append("/users/xuid("); path.Append(xboxUserId); path.Append(")/people"); if (!string.IsNullOrEmpty(relationshipType)) { path.Append("/"); path.Append(relationshipType); } if (isBatch) { path.Append("/batch"); } if ((decorations | SocialManagerExtraDetailLevel.None) != SocialManagerExtraDetailLevel.None) { path.Append("/decoration/"); if (decorations.HasFlag(SocialManagerExtraDetailLevel.TitleHistory)) { path.Append("titlehistory(" + this.appConfig.TitleId + "),"); } if (decorations.HasFlag(SocialManagerExtraDetailLevel.PreferredColor)) { path.Append("preferredcolor,"); } path.Append("presenceDetail"); } return(path.ToString()); }
/// <summary> /// Get profile information for a user. /// </summary> /// <param name="user">The user to get profile information for.</param> /// <param name="decorations">The additional detail to include in the response</param> /// <returns>Social profile information for the user.</returns> public Task <XboxSocialUser> GetProfileInfo(XboxLiveUser user, SocialManagerExtraDetailLevel decorations) { string path = "/users/me/people/xuids(" + user.XboxUserId + ")"; path += "/decoration/"; if ((decorations | SocialManagerExtraDetailLevel.None) != SocialManagerExtraDetailLevel.None) { if (decorations.HasFlag(SocialManagerExtraDetailLevel.TitleHistory)) { path += "titlehistory(" + this.appConfig.TitleId + "),"; } if (decorations.HasFlag(SocialManagerExtraDetailLevel.PreferredColor)) { path += "preferredcolor,"; } } // We always ask for presence detail. path += "presenceDetail"; XboxLiveHttpRequest request = XboxLiveHttpRequest.Create( this.httpCallSettings, HttpMethod.Get, this.peopleHubHost, path); request.ContractVersion = "1"; return(request.GetResponseWithAuth(user, HttpCallResponseBodyType.JsonBody) .ContinueWith(responseTask => { var response = responseTask.Result; JObject responseBody = JObject.Parse(response.ResponseBodyString); List <XboxSocialUser> users = responseBody["people"].ToObject <List <XboxSocialUser> >(); return users[0]; })); }
public Task AddLocalUser(XboxLiveUser user, SocialManagerExtraDetailLevel extraDetailLevel) { this.LocalUsers.Add(user); return(Task.FromResult(true)); }
public Task AddLocalUser(XboxLiveUser user, SocialManagerExtraDetailLevel extraDetailLevel) { this.LocalUsers.Add(user); this.events.Add(new SocialEvent(SocialEventType.LocalUserAdded, user, null)); return(Task.FromResult(true)); }
/// <summary> /// Gets the social graph details for a user. /// </summary> /// <param name="user">The user to request the social graph for.</param> /// <param name="decorations">The additional detail to include in the response</param> /// <returns>A list of all the users in the given users social graph.</returns> public Task <List <XboxSocialUser> > GetSocialGraph(XboxLiveUser user, SocialManagerExtraDetailLevel decorations) { return(this.GetSocialGraph(user, decorations, "social", null)); }
/// <summary> /// Gets the social graph details for a subset of the users in the given users social graph. /// </summary> /// <param name="user">The user to request the social graph for.</param> /// <param name="decorations">The additional detail to include in the response</param> /// <param name="xboxLiveUsers">The users to get social graph details for.</param> /// <returns>A list of the social information for the reuested set of users in the given users social graph.</returns> public Task <List <XboxSocialUser> > GetSocialGraph(XboxLiveUser user, SocialManagerExtraDetailLevel decorations, IList <string> xboxLiveUsers) { return(this.GetSocialGraph(user, decorations, string.Empty, xboxLiveUsers)); }
public void AddLocalUser(XboxLiveUser user, SocialManagerExtraDetailLevel extraDetailLevel = SocialManagerExtraDetailLevel.NoExtraDetail) { mLocalUsers.Add(user); mEvents.Add(new SocialEvent(SocialEventType.LocalUserAdded, user)); }
private static extern XSAPI_RESULT SocialManagerAddLocalUser(IntPtr user, SocialManagerExtraDetailLevel extraDetailLevel, IntPtr errMessage);