Beispiel #1
0
        /// <summary>
        /// Constructor. Creates a new connection to the GameSparks backend.
        /// </summary>
        /// <param name="name">Name of the instance. If an instance already exists with this name it will be returned </param>
        public static GSInstance GetInstance(string name)
        {
            if (Instances.ContainsKey(name))
            {
                return(Instances[name]);
            }

            GSInstance instance = new GSInstance(name);

            return(instance);
        }
 internal void Complete(GSInstance gsInstance, GSObject response)
 {
     _response = response;
     if (_completer != null)
     {
         _completer(response);
     }
     if (_errorCallback != null && response.ContainsKey("error"))
     {
         gsInstance.GSPlatform.ExecuteOnMainThread(() =>
         {
             _errorCallback(response);
         });
     }
     else if (_callback != null)
     {
         gsInstance.GSPlatform.ExecuteOnMainThread(() =>
         {
             _callback(response);
         });
     }
 }
Beispiel #3
0
        internal GSConnection(GSInstance gs, IGSPlatform gsPlatform, String currentUrl)
        {
            this._gs         = gs;
            this._gSPlatform = gsPlatform;
            url = currentUrl;

            mustConnectBy = DateTime.Now.AddMilliseconds(gs.HandshakeOffset).Ticks;

#if DEBUG
            if (GSInstance.customUrlBase.Length <= 0)
#endif
            {
                if (url.IndexOf('?') == -1)
                {
                    url += "?deviceOS=" + gsPlatform.DeviceOS;
                    url += "&deviceID=" + gsPlatform.DeviceId;
                    url += "&SDK=" + gsPlatform.SDK;
                }
            }

            _gSPlatform.DebugMsg("Connecting to:" + url);

            EnsureConnected();
        }
Beispiel #4
0
 /// <summary>
 /// This will end the remote session and stop all connections.
 /// </summary>
 public static void ShutDown()
 {
     Instance.ShutDown(null);
     _instance = null;
 }
 /// <summary>
 /// Create a new Request of the given type.
 /// </summary>
 /// <param name="instance">The GSInstance this request will be send with</param>
 /// <param name="type">Request type name</param>
 public GSTypedRequest(GSInstance instance, string type)
 {
     request = new GSRequest(instance, type);
 }
 /// <summary>
 /// Create a new request based on its type.
 /// This needs to be a valid requestType as exposed by the GameSparks Service.
 /// This is the base class for all requests.
 /// You should never need to use it directly.
 /// </summary>
 public GSRequest(GSInstance instance, string requestType)
 {
     this.gsInstance = instance;
     AddString("@class", "." + requestType);
 }