Problem with implementation

82 views
Skip to first unread message

michi

unread,
Jun 7, 2012, 2:02:35 PM6/7/12
to mogade-dev
Hi!

First, mogade is a really great soloution! But i get some trouble when
I try to implement it into my application. I used your example on
GitHub. The error says that GetLeaderbord is not included in the
Namespace Mogade!

Sry for my bad english and I hope you can help me,
Michi

Karl Seguin

unread,
Jun 7, 2012, 2:07:35 PM6/7/12
to moga...@googlegroups.com
Your english is great!

Can you show us the code?

GetLeaderboard is defined in MogadeClient of the WindowsPhone library:

Which is just a thin wrapper around the core C# library's Driver class:

Are you referencing the DLLs properly and instantiating the classes?

Karl

michi

unread,
Jun 7, 2012, 2:16:15 PM6/7/12
to moga...@googlegroups.com
I used the dll provided in the WP7 Sample App.  Here is the LoadLeaderboard method:

 private void LoadLeaderboard()
        {
            ScopeTitle.Text = _scope.ToString();
            //we can avoid the cross-thread issue by dispatching the entire callback, but don't do too much!
            Mogade.GetLeaderboard(MogadeHelper.LeaderboardId(Leaderboards.Main), _scope, _page, r => Dispatcher.BeginInvoke(() => LeaderboardReceived(r)));
            //could put a loading message here
        }

I underlined the sections where VS generates the error.

Karl Seguin

unread,
Jun 7, 2012, 3:15:25 PM6/7/12
to moga...@googlegroups.com
Is Mogade is a variable in your code? Or is it the Mogade namespace? If it' s the namespace, you are missing a few steps:

IMogadeClient mogade = MogadeClient.Initialize(_gameKey, _secret);
...

mogade.GetLeaderboard(.....)

michi

unread,
Jun 7, 2012, 3:52:46 PM6/7/12
to moga...@googlegroups.com
I have the same helper class used in the sample:

public enum Leaderboards
    {
        Main = 1,
    }
    public class MogadeHelper
    {
        //Your game key and game secret
        private const string _gameKey = "4fd056d0563d8a3d9500005b";
        private const string _secret = "6XAjSHn[D3r4N:SmIAE>u@n5fg";
        private static readonly IDictionary<Leaderboards, string> _leaderboardLookup = new Dictionary<Leaderboards, string>
                                                                                        {
                                                                                            {Leaderboards.Main, "4fd0cdab563d8a027b000035"}
                                                                                        };

        public static string LeaderboardId(Leaderboards leaderboard)
        {
            return _leaderboardLookup[leaderboard];
        }

        public static IMogadeClient CreateInstance()
        {
            //In your own game, when you are ready, REMOVE the ContectToTest to hit the production mogade server (instead of testing.mogade.com)
            //Also, if you are upgrading from the v1 library and you were using UserId (or not doing anything), you *must* change the UniqueIdStrategy to LegacyUserId
            MogadeConfiguration.Configuration(c => c.UsingUniqueIdStrategy(UniqueIdStrategy.UserId));
            return MogadeClient.Initialize(_gameKey, _secret);
        }


by the way: what do you mean with "REMOVE the ContectToTest to hit the production mogade server" ?

Karl Seguin

unread,
Jun 7, 2012, 3:58:50 PM6/7/12
to moga...@googlegroups.com
Oopps...you probably didn't mean to post your secret....I should make it so you can generate a new one...easily...but for now you might want to delete your game and create a new one.

As for the comment, that's for a line of code I deleted but the comment is still there. I'll remove it, you can ignore it for now.

What if you just try to simplify everything and take it from there?


var client = MogadeClient.Initialize(YOURKEY, YOURSECRET)
client.GetLeaderboard(YOUR_LEADERBOARD_ID, LeaderboardScope.Overall, 1, r => Dispatcher.BeginInvoke(() => LeaderboardReceived(r)));


Karl

michi

unread,
Jun 7, 2012, 4:06:51 PM6/7/12
to moga...@googlegroups.com
I will try it :)
The game i created was only a "test" so its now not so important to keep the secret secret.

michi

unread,
Jun 7, 2012, 4:51:10 PM6/7/12
to moga...@googlegroups.com
Looks like that it would work, but at the moment when I try to send a new score, I get an exception from json the application still work, but the sending process is "unlimeted" long, if you understand me :)

Karl Seguin

unread,
Jun 7, 2012, 8:40:13 PM6/7/12
to moga...@googlegroups.com
What's the exception message. There may also be an inner exception, what's its message?

michi

unread,
Jun 8, 2012, 3:39:27 AM6/8/12
to moga...@googlegroups.com
Eine Ausnahme (erste Chance) des Typs "System.IO.FileNotFoundException" ist in mscorlib.dll aufgetreten.
Eine Ausnahme (erste Chance) des Typs "System.Net.WebException" ist in System.Windows.dll aufgetreten.
Eine Ausnahme (erste Chance) des Typs "System.Net.WebException" ist in System.Windows.dll aufgetreten.
Eine Ausnahme (erste Chance) des Typs "System.MethodAccessException" ist in mscorlib.dll aufgetreten.
Eine Ausnahme (erste Chance) des Typs "Newtonsoft.Json.JsonSerializationException" ist in Newtonsoft.Json.WindowsPhone.dll aufgetreten.
Eine Ausnahme (erste Chance) des Typs "Newtonsoft.Json.JsonSerializationException" ist in Newtonsoft.Json.WindowsPhone.dll aufgetreten.

My Visual Studio is German so here the translation:

An exception (first chance) of type 'System.IO.FileNotFoundException' occurred in mscorlib.dll.

The same for all the other ones :)

Thanks for you help
Michi

Karl Seguin

unread,
Jun 8, 2012, 4:01:36 AM6/8/12
to moga...@googlegroups.com
First chance (or erste Chance) exception are often harmless.  Plenty of posts about it, this one is good:


Most people disable them in Visual Studio. Tools, Options, Debugging, General...I think.

Karl

michi

unread,
Jun 8, 2012, 4:06:46 AM6/8/12
to moga...@googlegroups.com
Yeah but the button where I should send the code stays for unlimeted time on Loading and I get no response from the server.

michi

unread,
Jun 8, 2012, 4:12:56 AM6/8/12
to moga...@googlegroups.com
if (!response.Success)
            {
                Debug.WriteLine(response);
            }

Here I get this output:

Mogade.Response`1[Mogade.LeaderboardScores]

Karl Seguin

unread,
Jun 8, 2012, 5:00:28 AM6/8/12
to moga...@googlegroups.com
Assuming you've told VS to stop exposing first chance exceptions, you should be able to get a lot of meaningful data by placing a breakpoint there and looking at response in details.

For example, what's response.Raw or response.Error.Message   or response.Error.InnerException.ToString()

michi

unread,
Jun 8, 2012, 5:17:22 AM6/8/12
to moga...@googlegroups.com
Just worked out that the remote server returned an errer: "Not found"

Karl Seguin

unread,
Jun 8, 2012, 5:23:16 AM6/8/12
to moga...@googlegroups.com
I couldn't find a leaderboard with an id of 4fd0cdab563d8a027b000035  are you sure you copied the right thing?

Karl

michi

unread,
Jun 8, 2012, 5:28:41 AM6/8/12
to moga...@googlegroups.com
I copyed the leaderboard id a second time, but it hasn't worked. Now I created another leaderboard. With this it works!!!! Thanks for your excellent help and mogade is a really great solution!
Yours, sincerely
michi

michi

unread,
Jun 8, 2012, 10:04:37 AM6/8/12
to moga...@googlegroups.com
My last question: Where can I say how much entries I get? For example I include a scroll viewer

Karl Seguin

unread,
Jun 8, 2012, 10:06:32 AM6/8/12
to moga...@googlegroups.com
You mean, how can you see the total number of scores?

There's a GetLeaderboardCount method.

Check out the IMogadeClient class:

It's fairly well documented and will give you an idea of what you can do.

Karl

michi

unread,
Jun 8, 2012, 10:11:01 AM6/8/12
to moga...@googlegroups.com
Not really, I have seen there is a int called page, but how many items are on one page?

Karl Seguin

unread,
Jun 8, 2012, 10:16:17 AM6/8/12
to moga...@googlegroups.com
It defaults to 10. There's an overload that lets you specify the number of records to return per page. The maximum you can set it to is 50.

If you want to know how many pages there are, you take the total number of scores and divide it by the number of records per page (10 by default, or whatever you specify).

Karl

michi

unread,
Jun 8, 2012, 12:18:59 PM6/8/12
to moga...@googlegroups.com
But if I set the records by page to 100 it still works :)

Karl Seguin

unread,
Jun 8, 2012, 12:20:36 PM6/8/12
to moga...@googlegroups.com
The server overrides it in that case and uses 50..or at least, it should be.  It won't give an error, it'll just force a maximum of 50.
Reply all
Reply to author
Forward
0 new messages