コード例 #1
0
        // 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"]);
            }
        }
コード例 #2
0
        private static ArrayList parseArrayList(Hashtable resultsDict)
        {
            ArrayList result = null;

            if (resultsDict["result"] != null)
            {
                result = (ArrayList)ZenJSON.Deserialize((string)resultsDict["result"]);
            }
            return(result);
        }
コード例 #3
0
        private static Hashtable parseHashtable(Hashtable resultsDict)
        {
            Hashtable result = null;

            if (resultsDict["result"] != null)
            {
                result = (Hashtable)ZenJSON.Deserialize((string)resultsDict["result"]);
            }
            return(result);
        }
コード例 #4
0
        private static ZDKError parseZDKError(Hashtable resultsDict)
        {
            ZDKError error = null;

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