Sign In Register

How can we help you today?

Start a new topic

blocking request.send()'s

Hi


I'm using the unity SDK and I am trying to send various requests that block the main thread. Am I misunderstanding something or is this no longer possible, and are all send requests now asynchronous? 




Please paste you code here.

Probably you are not using Send() , instead you might be using Send(callback). Send is blocked call where is Send with callback param is Asyc call.

 Thanks for your reply. I figured as much as that and something as below works fine (but asynchronously)

public void loginClick()
    {        
        AuthenticationRequest request = new AuthenticationRequest();
        request.SetUserName(username.text);
        request.SetPassword(password.text);
        request.Send(response =>
            {
                if (response.HasErrors)
                {                 
                    //Error
                }
                else
                {       
                    //Success
                 }
            });
    }

 

However when I try to just use the send method I get compiler errors:


   

    public void loginClick()
    {
        AuthenticationRequest request = new AuthenticationRequest();
        request.SetUserName(username.text);
        request.SetPassword(password.text);
        AuthenticationResponse response = request.Send();  //<--- Error
              
    }

   This gives me the error that 'no overload method "send" takes 0 arguments. What am I missing? :)

Kind of strange scenario :O


Can you please paste the exact error log here? (you mentioned send instead of Send above)


For me the same loginClick code is working fine!





the lower capital send was just me writing it manually. The error is as follows 

"Assets/LoginManager.cs(123,17): error CS1501: No overload for method `Send' takes `0' arguments"


It seems I only have four overloaded Send methods which are all asynchronos. I have just tried creating a new unity project and importing the GameSparks package again, but with the same result. Really strange :S

Please make sure you have the latest version. 


GSTypedRequest is the class that will have Send method. Just cross check in GameSparks dll in your mono if it has that method or not.


Wondering what could be the error :). I guess an update to latest SDK will be fine.

Funny because I do have the latest SDK update (Gamesparks_Unity_5.0.0.rc46.unitypackage) which gives the error. If I however use the older version (GameSparks_Unity_3.2.3.unitypackage) I can indeed use the Send() method. 


I have checked and the function declaration for Send() does not exist in 5.0.0 but it does in 3.2.3. May I ask what version you are using?

I just tested with new projects and version Gamesparks_Unity_5.0.0.rc46.unitypackage and GameSparks_Unity_3.2.3.unitypackage. The Send() method does not exist in the newest version (5.0.0) but it does indeed exist and work in 3.2.3. 


Unity is version 5.0.0f4. I find it hard to believe that the overloaded function should be missing from the newest SDK update without anyone else having the issue. May I ask  which version you are using?


Again I want to thank you for taking the time to help :) 

The error only occurs with the newest SDK (5.0.0) and not with the older SDK (3.2.3). The Send() is simply missing in the new SDK dll. Which version are you using?

This is the dll I get in version 5.0.0 


 

#region Assembly GameSparks.Api.dll, v3.0.0.0
// C:\Bgods - Gamespark\BattleGods-Development - Copy\Assets\Plugins\GameSparks.Api.dll
#endregion

using System;
using System.Collections.Generic;

namespace GameSparks.Core
{
    public abstract class GSTypedRequest<IN, OUT>
        where IN : GameSparks.Core.GSTypedRequest<IN, OUT>
        where OUT : GameSparks.Core.GSTypedResponse
    {
        protected GSRequest request;

        protected GSTypedRequest(string type);

        public IDictionary<string, object> JSONData { get; }
        public string JSONString { get; }

        protected abstract GSTypedResponse BuildResponse(GSObject response);
        //
        // Summary:
        //     Asyncronous send method, provide an Action to handle the callback.  It's
        //     the callers responsibility to validate whether the response has errors using
        //     response.HasErrors If the SDK is not connected, the default timeout will
        //     be used as defined in GSPlatform.RequestTimeoutSeconds
        public void Send(Action<OUT> callback);
        //
        // Summary:
        //     Asyncronous send method, provide an Action to handle a successful response
        //     and an Action to handle an error response.  If the SDK is not connected,
        //     the default timeout will be used as defined in GSPlatform.RequestTimeoutSeconds
        public void Send(Action<OUT> successCallback, Action<OUT> errorCallback);
        //
        // Summary:
        //     Asyncronous send method, provide an Action to handle the callback.  The timeoutSeconds
        //     parameter indicates how long the request will be queued for in case the SDK
        //     is not connected to the GameSparks service.  It's the callers responsibility
        //     to validate whether the response has errors using response.HasErrors
        public void Send(Action<OUT> callback, int timeoutSeconds);
        //
        // Summary:
        //     Asyncronous send method, provide an Action to handle a successful response
        //     and an action to handle an error response.  The timeoutSeconds parameter
        //     indicates how long the request will be queued for in case the SDK is not
        //     connected to the GameSparks service.
        public void Send(Action<OUT> successCallback, Action<OUT> errorCallback, int timeoutSeconds);
        public IN SetDurable(bool durable);
        public IN SetMaxQueueTimeInSeconds(int maxQueueTime);
        public IN SetMaxResponseTimeInSeconds(int maxResponseTime);
        public IN SetScriptData(GSRequestData data);
    }
}

 

Sorry, Yes you are right, Im not on 5.0 yet . I'm still on 3.0, just now I noticed :|

So I see this was never resolved...has the blocking/synchronous 'Send' mechanism been eliminated from the Unity SDK?

 So the Send() method requires a callback, and therefore there is no overloaded method which takes zero arguements.

The correct for for the callback is to supply the response with the callback.

.SetUserName(_userName)
 .SetPassword(_password)
 .Send((resp) => {

   // some code here

});

Translation  - there is no blocking method available any more (this doc is outdated - http://www.gamesparks.com/blog/unity-and-gamesparks/)


1 person likes this
Login to post a comment