LogEventRequest

Allows a user defined event to be triggered.

This call differs from most as it does not have a fixed format. The @class and eventKey attributes are common, but the rest of the attributes are as defined in the Event object configured in the dev portal.

The example below shows a request to an event with a short code of HS with 2 attributes, 'HS' & 'GL'.

View interactive version here

Request Parameters

Parameter Required Type Description
eventKey Yes string The short code of the event to trigger

Response Parameters

A response to a log event request

Parameter Type Description
scriptData ScriptData A JSON Map of any data added either to the Request or the Response by your Cloud Code

Nested types

ScriptData

A collection of arbitrary data that can be added to a message via a Cloud Code script.

Parameter Type Description
myKey string An arbitrary data key
myValue JSON An arbitrary data value.

Code Samples

C#

    using GameSparks.Api;
    using GameSparks.Api.Requests;
    using GameSparks.Api.Responses;
    ...
    new LogEventRequest()
        .SetEventKey(eventKey)
        .Send((response) => {
        GSData scriptData = response.ScriptData; 
        });

ActionScript 3

    import com.gamesparks.*;
    import com.gamesparks.api.requests.*;
    import com.gamesparks.api.responses.*;
    import com.gamesparks.api.types.*;
    ...

    gs.getRequestBuilder()
        .createLogEventRequest()
        .setEventKey(eventKey)
        .send(function(response:com.gamesparks.api.responses.LogEventResponse):void {
        var scriptData:ScriptData = response.getScriptData(); 
        });

Objective-C

    #import "GS.h"
    #import "GSAPI.h"
    ...
    GSLogEventRequest* request = [[GSLogEventRequest alloc] init];
    [request setEventKey:eventKey;
    [request setCallback:^ (GSLogEventResponse* response) {
    NSDictionary* scriptData = [response getScriptData]; 
    }];
    [gs send:request];

C++


    #include <GameSparks/generated/GSRequests.h>
    using namespace GameSparks::Core;
    using namespace GameSparks::Api::Responses;
    using namespace GameSparks::Api::Requests;
    ...

    void LogEventRequest_Response(GS& gsInstance, const LogEventResponse& response) {
    GSData scriptData = response.getScriptData(); 
    }
    ......

    LogEventRequest request(gsInstance);
    request.SetEventKey(eventKey)
    request.Send(LogEventRequest_Response);

Java

import com.gamesparks.sdk.api.autogen.GSRequestBuilder.LogEventRequest;
import com.gamesparks.sdk.api.autogen.GSResponseBuilder.LogEventResponse;
import com.gamesparks.sdk.api.autogen.GSTypes.*;
import com.gamesparks.sdk.api.GSEventListener;

...
gs.getRequestBuilder().createLogEventRequest()
    .setEventKey(eventKey)
    .send(new GSEventListener<LogEventResponse>() {
        @Override
        public void onEvent(LogEventResponse response) {
            GSData scriptData = response.getScriptData(); 
        }
    });

Cloud Code


    var request = new SparkRequests.LogEventRequest();
    request.eventKey = ...;
    var response = request.Send();

var scriptData = response.scriptData; 
Did this page help you? Please enter your feedback below. For questions about using this part of the platform, please contact support here