Ejemplo n.º 1
0
            private void ObexRequestHandler()
            {
                if (radio == null)
                {
                    return;
                }

                while (listener.IsListening)
                {
                    try
                    {
                        ObexListenerContext_M1 olc = listener.GetContext_M1(download_path, p =>
                        {
                            //Console.WriteLine("{0}, {1}, {2}, {3}, {4}, {5}", p.Command, p.FileCount, p.FileSize, p.FileName, p.FileIndex, p.CurrentBytes);
                            string filename = "";
                            if (p.FileName != null)
                            {
                                filename = p.FileName.Replace("\\", "\\\\");
                            }

                            Console.Write("{");
                            Console.Write("  \"command\": \"{0}\",", p.Command);
                            Console.Write("  \"file_count\": {0},", p.FileCount);
                            Console.Write("  \"file_size\": {0},", p.FileSize);
                            Console.Write("  \"file_path\": \"{0}\",", filename);
                            Console.Write("  \"file_index\": {0},", p.FileIndex);
                            Console.Write("  \"file_bytes\": {0}", p.CurrentBytes);
                            Console.Write("}");
                            Console.Write("\n");
                        });
                        //ObexListenerRequest olr = olc.Request;
                        //string filename = System.Environment.GetFolderPath(System.Environment.SpecialFolder.Personal) + "\\" + DateTime.Now.ToString("yyMMddHHmmss") + " " + Uri.UnescapeDataString(olr.RawUrl.TrimStart(new char[] { '/' }));
                        //olr.WriteFile(filename);
                        //Console.WriteLine("file: " + filename);

                        //dispatcher.Invoke(new Action(delegate()
                        //{
                        //    Console.WriteLine("aaa: ");
                        //}));
                    }
                    catch (Exception ex)
                    {
                        break;
                    }
                }
            }