Closed misterjoshm closed 7 years ago
Thanks, done
Is there a possibility that you can grant me rights to create a feature branch to work on, so that I can periodically checkin my work for you to review until it's completed?
In the upper right, click "Fork" to make your own fork. Then clone into that, and you'll have full read/write access. When you done, then submit a pull request. Thanks
I'm still working on this. It's going to take some time. Fast is relative sometimes :).
No worries. Thanks for the help
No problem. Thanks for the opportunity!
So I just updated my branch strangegraphs_csharp_creators_feature. Can you take a look and see what you think so far? As a start, I am planning to take your current code, and put it into a dll. Then we can expose the necessary functions via the dll in a csharp class library. Then I'll write a test function like a uwp app that does the basic functions. I want to see if you like where I'm going with that before taking the next step and making the necessary functions in the dll, or if it would be better some other way. I'm open for suggestions, but I think this will be the best way to start.
No need for such complex work. Our WinRT DLL & nuget package already supports C# due to magic of WinRT.
Here's a C# test app that links to our WinRT source: https://github.com/Microsoft/xbox-live-api/tree/master/Tests/CppCxTests/Social/UWP.
This can be change into a C# sample by removing the source linkage and following the "How to link against the XSAPI WinRT UWP source" here: https://github.com/Microsoft/xbox-live-api/blob/master/LINKTOSOURCE.md#how-to-link-against-the-xsapi-winrt-uwp-source
There's more detail in step 2 of: https://docs.microsoft.com/en-us/windows/uwp/xbox-live/get-started-with-creators/develop-creators-title-with-visual-studio
Thanks, Jason
Thanks Jason! I'll start again and look at the way that you suggested!
@jasonsandlin Hi Jason. I made another push with some changes based on your suggestions. Before I go further with it will you look once again. It's much more simple now after your suggestions. I think I can get the rest of the needed functions in the class library relatively easy. I started over and my new branch is called strangegraphs_csharp_xbox_live
Looks fine, but I personally wouldn't bother writing such thin wrapper apis.
For example, instead of:
IReadOnlyList<string> GetStat(Page page, XboxLiveContext xboxLiveContext)
{
StatisticManager statisticManager = StatisticManager.SingletonInstance;
if (statisticManager == null)
{
return null;
}
return statisticManager.GetStatisticNames(xboxLiveContext.User);
}
It could be just:
IReadOnlyList<string> GetStat(Page page, XboxLiveContext xboxLiveContext)
{
return StatisticManager.SingletonInstance.GetStatisticNames(xboxLiveContext.User);
}
and then I wouldn't bother with this wrapper function, just call the StatisticManager API directly.
Scenario_WriteStat for example shouldn't always call requestflush. You only want to do that when something important happens, not every time a stat is changed. If you don't call it, it'll upload automatically every 5 mins. If something important happens (level ends, etc) then call request flush.
Same stuff for the other functions.
Personally I would change those functions so the make the API call and then set the data in the sample's UI so they are separate but from the rest of the sample code, but are doing something that isn't just a thin wrap around the WinRT API.
Ok. I'll take the next step then and have the ui do something with the values. I kind of like the wrapper functions because it shows me which functions to call at certain times. Now I'll have it do something in the ui.
I have a semi quick question. I keep getting this error when I try to create an xbox live context object in uwp
Resource Contexts may not be created on threads that do not have a CoreWindow. WinRT information
Here is my snippet of code. Can you give me an idea of what I'm doing wrong? Thanks :)
public async Task<bool> SignInUser()
{
try
{
CoreWindow.GetForCurrentThread().Activate();
XboxLiveUwpImplementation xboxSocialObject = new XboxLiveUwpImplementation();
var t = (await Windows.System.User.FindAllAsync())[0];
XboxLiveUser xboxLiveUser = new XboxLiveUser(t);
var xboxLiveContext = new Microsoft.Xbox.Services.XboxLiveContext(xboxLiveUser);
return await xboxSocialObject.SignInXboxUser(this, xboxLiveContext);
}
catch (Exception ex)
{
}
return false;
}
private async void Button_Click(object sender, RoutedEventArgs e)
{
await SignInUser();
}
Pass in the Windows.UI.Xaml.Window.Current.CoreWindow.Dispatcher into SignIn like this C# test app does here:
https://github.com/Microsoft/xbox-live-api/blob/master/Tests/CSharpTestApp/UWP/MainPage.xaml.cs#L152
Thanks Jason!
ok my project was signing people in as of this morning. But now it's crashing. I have to look into that a little bit. I'm going to work on the ui and make a function for each button :)
Get token from IDP failed with ResponseStatus:1
I'll keep at it. I'll get it working better soon :)
I think that it was a problem with visual studio or my computer because when I rebooted everything it started working a little better. Now I'm trying it on the xbox one though and it's having a different error. I'll keep working on it.
WinRT information: Provider error: Unexpected response code: Unknown, Error Code: 0x80131509
I removed my xbox user and re-added it and then the sign in worked :)
xbox live is down so I guess I'll stop for tonight and try again tomorrow :)
Hi Jason. I think that I'm going to restart and take your advice and not use the tiny wrapper functions. It's causing problems that I didn't expect. At least I have more of a background of how it all works now. I'll keep working on it :)
No worries. You might want to start with the working C# test app that links to our WinRT source: https://github.com/Microsoft/xbox-live-api/tree/master/Tests/CppCxTests/Social/UWP.
To make it a C# sample, removing the source linkage and following the "How to link against the XSAPI WinRT UWP source" here: https://github.com/Microsoft/xbox-live-api/blob/master/LINKTOSOURCE.md#how-to-link-against-the-xsapi-winrt-uwp-source
and then change it as you see fit
sounds good :) Thanks. I'll give it another shot
shoot I took a few days to update my game. I got the sign in part working and my game approved for the creators club... Hey I was thinking though. For this example that I'm putting out, I could maybe clean up my code a bit and put out my game code as an example... It could be a little bit of publicity for my game and maybe help some people get started if they're working in 2d. Of course the art would be copyrighted, but the code they could use as a starting point to use for something else... I've been having a hard time getting approved for id though... But I think games like space whip could really be useful for the xbox platform if they would approve it and maybe even fund it. I can't make something super cool without more options though. It would probably take me at least a couple of weeks to get my game code clean enough to make it easily usable by other people... Do you think that this would be useful? It's pretty basic at the moment. You can see my game in the creators collection on xbox one if you want to check it out sometime, or I could do a more basic example like we have already talked about if you think that would be more useful.
Josh
Game source is sometimes useful to learn from and sometimes its tricky since they do so much its hard to pull out the pieces that are interesting for other game devs to copy/paste into their project.
That said, you can share whatever you like in your own GitHub repo or elsewhere on the net using whatever license you want and then share links to it. But of course in this Microsoft repo, I can't take pull requests involving copyrighted art or source. For this repo, I prefer to keep it to just samples that show off a single topic with little else so its clear and hopefully easily copy/pasted into other projects.
Makes sense. Thanks :)
I almost have some things to check in
Shoot Some things came up at my job that are requiring more of my attention. I'm still working on it, just really slowly.
No worries. How about we just close this open issue and you just submit a pull request when your done?
That sounds good. Thanks.
I'll let you close it ok
@strangegraphs Did you ever get leaderboards working in c#?
@CartBlanche I didn't. Sorry about that? @jasonsandlin Hey do you guys want me to give this another shot? I lost track of it.
@strangegraphs that's a pity. My C# game is able to log into Xbox Live. It receives the leaderboard complete event-type message with error code 0, but the moment I try to access the EventArgs property it blows up big time and throws a "No encontrado (404)" exception message. Odd the message is in Spanish. Seems to be coming from the COM interop.
Anyway I'm happy to work with you to get this working, if possible, so other .Net folk don't have the same headaches. Its the last piece I need to get working in my game.
please assign this to me. I'll try to make it work soon!