Beispiel #1
0
        private static IEnumerator SendRequest(UnityWebRequest request, SortedDictionary <string, string> parameters, string method, string requestURL, TwitterCallback callback)
        {
            request.SetRequestHeader("Authorization", Oauth.GenerateHeaderWithAccessToken(parameters, method, requestURL));
            yield return(request.SendWebRequest());

            if (request.isNetworkError)
            {
                callback(false, JsonHelper.ArrayToObject(request.error));
            }
            else
            {
                if (request.responseCode == 200 || request.responseCode == 201)
                {
                    callback(true, JsonHelper.ArrayToObject(request.downloadHandler.text));
                }
                else
                {
                    Debug.Log(request.responseCode);
                    callback(false, JsonHelper.ArrayToObject(request.downloadHandler.text));
                }
            }
        }
Beispiel #2
0
        protected override bool ReceiveData(byte[] data, int dataLength)
        {
            if (data == null || data.Length < 1)
            {
                Debug.Log("LoggingDownloadHandler :: ReceiveData - received a null/empty buffer");
                return(false);
            }
            string response = Encoding.ASCII.GetString(data);

            response    = response.Replace("\"event\":", "\"event_name\":");
            messageType = StreamMessageType.None;
            CheckMessageType(response);
            try
            {
                callback(JsonHelper.ArrayToObject(response), messageType);
                return(true);
            } catch (System.Exception e)
            {
                Debug.Log("ReceiveData Error : " + e.ToString());
                return(true);
            }
        }