// Game Message Callbacks

        public static void CallbackResponse(string results)
        {
            Hashtable resultsDict = (Hashtable)ZenJSON.Deserialize(results);
            String    methodName  = resultsDict["methodName"] as String;

            if (ActionCallbacks.ContainsKey(resultsDict["callbackId"]))
            {
                Type[] parms = ActionCallbacks[resultsDict["callbackId"]].GetType().GetGenericArguments();
                Type   arg1  = parms[0];

                if (arg1 == typeof(byte[]))
                {
                    Action <byte[], ZDKError> callback = (Action <byte[], ZDKError>)ActionCallbacks[resultsDict["callbackId"]];
                    callback(parseByteArray(resultsDict), parseZDKError(resultsDict));
                }
                else if (arg1 == typeof(Hashtable))
                {
                    Action <Hashtable, ZDKError> callback = (Action <Hashtable, ZDKError>)ActionCallbacks[resultsDict["callbackId"]];
                    callback(parseHashtable(resultsDict), parseZDKError(resultsDict));
                }
                else
                {
                    Action <ArrayList, ZDKError> callback = (Action <ArrayList, ZDKError>)ActionCallbacks[resultsDict["callbackId"]];
                    callback(parseArrayList(resultsDict), parseZDKError(resultsDict));
                }
                ActionCallbacks.Remove(resultsDict["callbackId"]);
            }
            else
            {
                Debug.Log("ERROR: " + methodName + " - Missing callbackId for action in results.  Key = " + resultsDict["callbackId"]);
            }
        }
        private static ArrayList parseArrayList(Hashtable resultsDict)
        {
            ArrayList result = null;

            if (resultsDict["result"] != null)
            {
                result = (ArrayList)ZenJSON.Deserialize((string)resultsDict["result"]);
            }
            return(result);
        }
        private static Hashtable parseHashtable(Hashtable resultsDict)
        {
            Hashtable result = null;

            if (resultsDict["result"] != null)
            {
                result = (Hashtable)ZenJSON.Deserialize((string)resultsDict["result"]);
            }
            return(result);
        }
        private static ZDKError parseZDKError(Hashtable resultsDict)
        {
            ZDKError error = null;

            if (resultsDict["error"] != null)
            {
                error = new ZDKError((Hashtable)ZenJSON.Deserialize((string)resultsDict["error"]));
            }
            return(error);
        }
 public static void SetCustomFields(Hashtable fields)
 {
     Instance.Do("setCustomFields", ZenJSON.Serialize(fields));
 }
예제 #6
0
        /// <summary>
        /// Set current user field info. The callback provides a Hashtable of string-string pairs representing the new user fields.
        /// </summary>
        /// <param name="fields">A hashtable of string-string pairs representing custom user info.</param>
        /// <param name="callback">block callback executed on error or success states</param>
        public static void SetUserFields(Hashtable fields, Action <Hashtable, ZDKError> callback)
        {
            string fieldJson = ZenJSON.Serialize(fields);

            instance().Call("setUserFields", callback, fieldJson);
        }