Sign In Register

How can we help you today?

Start a new topic

UE4 and C++

Hi there,

First i must say that im learning c++ so im far to be an expert and i just started to work with GameSparks but im trying to figure why using static function for every request response instead of multicast delegate like the OnGameSparksAvailableDelegate? Having to deal with static response can be such a pain with non static members and everything else.

2 people have this question

I am running into the same issue.

My UE4 class needs access to the object the event was sent from. However, the way it's set up I can seemingly only use static functions.

I tried to bind it using non-static like so:  EventRequest.Send(&ASMission::Load_Response);   but that did not work unfortunately (result: a wall of errors)

How can we bind non-static functions to LogEventRequest classes?

2 people like this
Is it possible to have an answer on this? In its current state the SDK seems to usable only in blueprint which can be a real pain for all game logics. More delegates have to be added in the gamesparks component or maybe the listener. Also, exemple in the doc that do more than just AddOnScreenDebugMessage, maybe you will realize how bad it is to have everything in static function in UE4 since almost everything in the engine rely in non static. GameSparks have a great portal and many pro, but if the game engine integration is bad and not functional it's doesn't worth anything.

Any feedback on this?

 Hi guys,

Check the attached file which is part of our example project. Does code like this suit you better?

Here's a snippet:


GameSparks::Core::GS& gs = UGameSparksModule::GetModulePtr()->GetGSInstance();

        // attach the message listeners
        // MatchFoundMessage
        gs.SetMessageListener<MatchFoundMessage>([&](GS& gsInstance, const MatchFoundMessage& message) {
            GEngine->AddOnScreenDebugMessage(-1, 10.f, FColor::Yellow, TEXT("MatchFoundMessage"));

            gameSession = TSharedPtr<GameSparks::RT::IRTSession>(GameSparks::RT::GameSparksRT::SessionBuilder()


        // MatchNotFoundMessage
        gs.SetMessageListener<MatchNotFoundMessage>([&](GS& gsInstance, const MatchNotFoundMessage& message) {
            GEngine->AddOnScreenDebugMessage(-1, 10.f, FColor::Yellow, TEXT("MatchNotFoundMessage"));
            SendMatchmakingRequest(gs); // try again

        // MatchUpdatedMessage
        gs.SetMessageListener<MatchUpdatedMessage>([&](GS& gsInstance, const MatchUpdatedMessage& message) {
            GEngine->AddOnScreenDebugMessage(-1, 10.f, FColor::Yellow, TEXT("MatchUpdatedMessage"));

        //Construct an Authentication request
        // send a device authentication request with a random device id.
        // this is done so that you can start two instances on the same machine.
        // In a production title, you'd use IGSPlatform::GetDeviceId() instead.
        GameSparks::Api::Requests::DeviceAuthenticationRequest authRequest(gs);
        std::stringstream fake_device_id;
        fake_device_id << std::rand();
        authRequest.SetDeviceId(fake_device_id.str()); // generate a random device id (for easy testing)

        //Send it with a pointer to the function that will handle the response




(6.54 KB)


 MatchFoundMessage is undefined for me. Is it something I haven't included perhaps? Please help


MatchFoundMessage its work , but this :


gameSession = TSharedPtr<GameSparks::RT::IRTSession>(GameSparks::RT::GameSparksRT::SessionBuilder()

 this code not working  i got error here ".SetListener(this)"  

i find solution you cannot use "this" as a listener ,,,,  i was create the session successfully , but   i have another problem ,,,,, i do not understand how i can receive packets , how the delegate run with your code????????

you just show how to create session , can you please explain how can i  receive respond at OnReady delegate for example?

Login to post a comment