Exemplo n.º 1
0
        internal static int GetRequest(TripleCareServerResponseCallback callback, string host, string method, params object[] parameters)
        {
            var callJson = JToken.FromObject(new
            {
                @jsonrpc = "2.0", method,
                @params  = parameters
            });
            var request = new ServerRequest(host, "/triplecare/JsonRpcHandler.php?call=" + callJson.ToString(Formatting.None), callback);

            GetRequest(request);
            return(request.Id);
        }
Exemplo n.º 2
0
        internal static void GetRequest(ServerRequest request)
        {
            RequestQueue.Enqueue(request);

            if (_dispatchThread == null || _dispatchThread.ThreadState != Thread.eThreadStates.ThreadRunning)
            {
                _dispatchThread = new Thread(specific =>
                {
#if true
                    CrestronConsole.PrintLine("Launching TripleCare.DispacthThread, Request Count = {0}", RequestQueue.Count);
#endif

                    while (RequestQueue.Count > 0)
                    {
                        if (!HttpClient.ProcessBusy)
                        {
#if true
                            CrestronConsole.PrintLine("TripleCare.HttpClient available, dispatching ...");
#endif
                            var r = RequestQueue.Dequeue();
#if true
                            CrestronConsole.PrintLine("{0} {1}", r.RequestType.ToString(), r.Url);
                            if (r.RequestType == RequestType.Post)
                            {
                                CrestronConsole.PrintLine(r.ContentString);
                            }
#endif
                            var response = HttpClient.Dispatch(r);
                            r.Callback(r.Id, response);
                        }

                        CrestronEnvironment.AllowOtherAppsToRun();
                    }

                    return(null);
                }, null);
            }
        }