Example #1
0
        void basicNoUIObj_Synchronizing(object sender, WinWrap.Basic.Classic.SynchronizingEventArgs e)
        {
            string data = Convert.ToBase64String(Encoding.UTF8.GetBytes(e.Param)) + "\r\n";

            if (e.Id >= 0)
            {
                // response for a specific remote
                ApplicationQueue response = null;
                if (!responses_.TryGetValue(e.Id, out response))
                {
                    response = ApplicationQueue.Create("responses", LabelTarget.Text, e.Id.ToString());
                    responses_.Add(e.Id, response);
                }

                response.Append(data);
            }
            else
            {
                // response for all remotes
                foreach (ApplicationQueue response in responses_.Values)
                {
                    response.Append(data);
                }
            }
        }
Example #2
0
 protected void ButtonDebug_Click(object sender, EventArgs e)
 {
     //responses_.Append("Debug");
     //Thread.Sleep(1000);
     commands_  = ApplicationQueue.Create("commands", LabelTarget.Text);
     responses_ = new Dictionary <int, ApplicationQueue>();
     WinWrapExecute(true);
     foreach (ApplicationQueue response in responses_.Values)
     {
         response.Delete();
     }
 }
Example #3
0
        public void ProcessRequest(HttpContext context)
        {
            ApplicationQueue responses = null;

            // read the request
            context.Request.InputStream.Seek(0, SeekOrigin.Begin);
            using (StreamReader sr = new StreamReader(context.Request.InputStream))
            {
                string text = sr.ReadToEnd();
                //Debug.Write(text);
                if (text.StartsWith("Commands:"))
                {
                    int x = text.IndexOf("\r\n");
                    if (x > 0)
                    {
                        int target = 0;
                        if (int.TryParse(text.Substring(9, x - 9), out target))
                        {
                            text = text.Substring(x + 2);
                            ApplicationQueue commands = ApplicationQueue.Create("commands", target.ToString());
                            commands.Append(text);
                            string[] parts = text.Split(new char[] { ' ' }, 2);
                            if (parts.Length == 2)
                            {
                                int id = 0;
                                if (int.TryParse(parts[0], out id))
                                {
                                    responses = ApplicationQueue.Create("responses", target.ToString(), id.ToString());
                                }
                            }
                        }
                    }
                }
            }

            // send the response
            {
                // Access-Control-Allow-Origin: *
                // Access-Control-Allow-Headers: X-Requested-With
                context.Response.AddHeader("Access-Control-Allow-Origin", "*");
                context.Response.AddHeader("Access-Control-Allow-Headers", "X-Requested-With");
                context.Response.ContentType     = "text/plain";
                context.Response.ContentEncoding = Encoding.UTF8;
                string text = responses != null?responses.ReadAll() : null;

                //Debug.Write(text);
                context.Response.Write("Responses:\r\n" + text);
            }
        }