Blocking Example for GameSparksApi.mySyncLogEventRequest
J
Jason Fuller
started a topic
over 8 years ago
Can you please provide an example on how to use the above request for blocking.
I am trying to call some information in from an event (call it "myevent") but when using myAsyncLogEventRequest it returns before the data is received, therefore is null. but when I attempt the above call in a blocking manner, it errors in unity stating "Cannot implicitly convert type `System.Collections.Generic.IDictionary<string,object>' to `GameSparks.GameSparksSender"
So far I have been unable to find any example on how to use this request in a blocking style forcing a wait until the data is returned before calling the completionfunction.
Current code is as follows:
public IDictionary<string, object> getplayercharacter(string userid)
{
Debug.Log ("Player Data Requested");
Dictionary<string, object> parameters = new Dictionary<string, object>();
parameters.Add("UserID",userid);
//GameSparksApi.mySyncLogEventRequest("GetPChar",parameters);
GameSparksSender sender=GameSparksApi.mySyncLogEventRequest("GetPChar",parameters);
//GameSparksApi.logEventRequest("GetPChar").sendAsync(delegate(IDictionary<string,object> response)
sender.sendAsync(testcloudcodecompletion);
return playerdata;
}
Best Answer
T
Tech Support
said
over 8 years ago
Hi Jason
GameSparksSender has 2 methods for sending, sendAsync (which you are using now) is an asyncronous send, so will not block. You should use the send() method if you want to block.
GameSparksSender has 2 methods for sending, sendAsync (which you are using now) is an asyncronous send, so will not block. You should use the send() method if you want to block.
Change the last 2 lines from :
sender.sendAsync(testcloudcodecompletion);
return playerdata;
To:
return sender.send();
That should do it.
Gabriel
J
Jason Fuller
said
over 8 years ago
Thank you. that done the trick. So simple that I didn't see it :)
I was attempting to use sender.send(testcloudcodecompletion); which is where I went wrong.
Using your example it seems to be working using IDictionary<string,object> results=sender.send(); testcloudcodecompletion(results);
now sending in the correct order (rather than reversing for some reason) and letting the first complete before doing the second.
D
David Serrano
said
over 5 years ago
Does the GameSparksSender class no longer exist? How can I make a call that blocks until the answer arrives?
Jason Fuller
Can you please provide an example on how to use the above request for blocking.
I am trying to call some information in from an event (call it "myevent") but when using myAsyncLogEventRequest it returns before the data is received, therefore is null. but when I attempt the above call in a blocking manner, it errors in unity stating "Cannot implicitly convert type `System.Collections.Generic.IDictionary<string,object>' to `GameSparks.GameSparksSender"
So far I have been unable to find any example on how to use this request in a blocking style forcing a wait until the data is returned before calling the completionfunction.
Current code is as follows:
Hi Jason
GameSparksSender has 2 methods for sending, sendAsync (which you are using now) is an asyncronous send, so will not block. You should use the send() method if you want to block.
Change the last 2 lines from :
sender.sendAsync(testcloudcodecompletion);
return playerdata;
To:
return sender.send();
That should do it.
Gabriel
- Oldest First
- Popular
- Newest First
Sorted by Oldest FirstTech Support
Hi Jason
GameSparksSender has 2 methods for sending, sendAsync (which you are using now) is an asyncronous send, so will not block. You should use the send() method if you want to block.
Change the last 2 lines from :
sender.sendAsync(testcloudcodecompletion);
return playerdata;
To:
return sender.send();
That should do it.
Gabriel
Jason Fuller
Thank you. that done the trick. So simple that I didn't see it :)
I was attempting to use sender.send(testcloudcodecompletion); which is where I went wrong.
Using your example it seems to be working using IDictionary<string,object> results=sender.send(); testcloudcodecompletion(results);
now sending in the correct order (rather than reversing for some reason) and letting the first complete before doing the second.
David Serrano
Does the GameSparksSender class no longer exist? How can I make a call that blocks until the answer arrives?
-
Documentation Notes
-
Design issues with user events
-
Using NoSQL
-
Runtime Collections vs Metadata Collections
-
Anonymous authentication from browser app
-
Modules
-
Movement With Unity
-
Problem with url parameters for downloadables
-
Querying NoSql GameSparks database
-
Challenge accesType
See all 2487 topics