Sign In Register

How can we help you today?

Start a new topic

c++ sdk

Hi


in C++ sdk, setEventAttribute function of LogEventRequest is missing some type of number.

    

LogEventRequest& SetEventAttribute(const gsstl::string& key, long value)
LogEventRequest& SetEventAttribute(const gsstl::string& key, int value) 

    

but the flowing function should be added,

  

LogEventRequest& SetEventAttribute(const gsstl::string& key, float value)
LogEventRequest& SetEventAttribute(const gsstl::string& key, double value)
LogEventRequest& SetEventAttribute(const gsstl::string& key, long long value)
LogEventRequest& SetEventAttribute(const gsstl::string& key, bool value)

Or the argument will be converted to 32-bit integer.


Thanks,

Jo


 Thanks for the feedback Jo!


we'll have a look at this.


Cheers,

Omar

Hi Omar


I saw there is an update of sdk few days ago.


these 2 are still missing:

LogEventRequest& SetEventAttribute(const gsstl::string& key, long long value)
LogEventRequest& SetEventAttribute(const gsstl::string& key, bool value)

 I'm not a c++ expert, just wondering why it's not necessary.


Thanks,

Jo

Hi Jo,


You can add the bool to a JSON and get it from there. Im not sure about long, will have to ask the SDK team why they didnt include it.


Cheers,

Omar

Hi Omar,


I saw the latest update (version 1.1.16.1531) deleted the functions again.


image


Please check it.


Jo

Hi Jo,

Sorry about this, will chase up the SDK team about it.

Cheers for the feedback,
Omar

 

 Hey Jo,


Sorry, I got a little confused. Why would you want to pass in a float via the event attribute? You can do that via a nested value in an object:


//Create an object to store float, boolean, int and string values and reference them using keys.
GSRequestData scriptData;

//Populate the object by assigning a key first, and a value. This key will be used to refer to the data in cloud code.
scriptData.AddNumber("key", 23.45);

//Set the object as the scriptData GSRequestData object we created
request.SetEventAttribute("objVal", scriptData);

 

You can then get the nested value in Cloud Code like this:


Spark.getData().objVal.key

 


The reason we won't implement the number attribute to take a float is that it could cause errors on the backend because a few areas of the backend dont work with floats.


Hope this helps,

Omar

 

 Sorry also I just realised I didn't do well to answer your question at all. I got confused. All the extra values you want can be set using the GSRequestData and passed in through SetEventAttribute. This is because the backend is set to accept one of three input types, Number, String and JSON. Those values are used in the JavaScript used to run the backend.


JSON is used to include all the values.


Hope this answers your question,

again, apologies,

Omar

Hi Omar,


I got confused.


1. Can I pass a float value to "setEventAttribute"? Actually I'm doing it in production env. since a long time ago. Because Number type in Javascript includes float number.


2. If I can, then the setEventAttribute  of c++ sdk should accept float input.


Please clarify.


Thanks,

Jo

 Hi,


Yes, Cloud Script accepts number as float. However, if we allow this from the SDK and developers start using it to post their scores to leaderboards by inserting floats we'll be running to a lot of fatal errors. It is a precautionary measure.


Cheers,

Omar

Hi, Omar


I see.

It prevents the errors of leaderboard.

However, I need to pass floats to cloud code and it's on live env. .

So I probably have to stay with older version of SDK that supports it.


And I think to prevent the fatal errors of leaderboard, you should return error response to tell developers, instead of forbid the possible usage for cloud code.


And for example, you cannot forbid it for Restful api or javascript SDK.

The potential errors still happens.

In addition, there seems no documentation that says you cannot use floats in the situation you mentioned.


Thanks anyway.

Jo

Login to post a comment