Sign In Register

How can we help you today?

Start a new topic
Answered

AchievementEarnedMessage

I am new to the platform and I was working through the Achievements example.

I was trying to get notification of the achievement being earned.


I have added a listener in the Awake of my unity code.

If i add the achievement through the test harness the callback for AchievementEarnedMessage is never called.
If i add the achievement through code on the unity side the AchievementEarnedMessage is called.

Looking at the account details in both cases i can see the achievement has been added to the player.


Is there something different about the way the test harness dispatches messages?


Also this achievement is set to be multiple uses if that might make a difference.


Thanks


Best Answer

Hi Jermey,


Sorry, I misunderstood your initial question...


You are correct, messages are fired once. The first listener to catch this message will prevent it from reaching the others. Given that the test harness is located on the same network, it naturally always hits there first.


The best way to test this in my opinion is with two user accounts, the user logged into the Test Harness sends the user in the Client a message and it should be received there.


It is worth mentioning though that even thought the message is received by the Test Harness, it should be visible to the Client using ListMessageRequest. If you expect users to be logged into multiple devices it may beneficial to also check this every X seconds to ensure the client hasn't missed any vital information.


I'll investigate if we can circumvent this design and get back to you shortly.


Shane


Hi Jeremy,


Trying to replicate the issue, but even repeated awarding of the achievement is showing the message in my test harness:




Can you try clearing your cache and logging out of GameSparks and back in again?


Shane


Thanks


But I also see the achievement awarded. But it is on the client side that I am having the issue.

I have registered for this message in Awake
        GameSparks.Api.Messages.AchievementEarnedMessage.Listener += Achievmentshandler;


When I go to the test harness and award the achievement this code is never called.

If on the client i award the achievement the message handler is called.

        new GameSparks.Api.Requests.LogEventRequest().SetEventKey("Award_Achievement").Send((response)


I think I figured it out. Can you confirm this as well.

I had the idea over the weekend that it might be an issue with adding the achievement to the same player that logged in to the test harness.

That the test harness might be eating the message before its delivered to the client.

I modified the cloud code to add the achievement to a specific player and then logged into the test harness using a different player.


Now after adding the achievement and returning to the unity client I see the achievement handler being called.


If this is the correct behavior is there a way around this? 

Answer

Hi Jermey,


Sorry, I misunderstood your initial question...


You are correct, messages are fired once. The first listener to catch this message will prevent it from reaching the others. Given that the test harness is located on the same network, it naturally always hits there first.


The best way to test this in my opinion is with two user accounts, the user logged into the Test Harness sends the user in the Client a message and it should be received there.


It is worth mentioning though that even thought the message is received by the Test Harness, it should be visible to the Client using ListMessageRequest. If you expect users to be logged into multiple devices it may beneficial to also check this every X seconds to ensure the client hasn't missed any vital information.


I'll investigate if we can circumvent this design and get back to you shortly.


Shane

Login to post a comment