예제 #1
0
        private void EndSend(IAsyncResult res)
        {
            if (!working)
            {
                return;
            }
            args a = (args)res.AsyncState;

            try
            {
                int k = a.s.EndSend(res);
                a.cnt += k;
                if (a.cnt < a.buffer.Length)
                {
                    a.s.BeginSend(a.buffer, a.cnt, a.buffer.Length - a.cnt,
                                  SocketFlags.None, EndSend, a);
                    return;
                }
            }
            catch { }
            a.buffer = new byte[byte.MaxValue];
            a.cnt    = 0;
            a.data.Clear();
            a.s.BeginReceive(a.buffer, 0, a.buffer.Length, SocketFlags.None,
                             EndReceive, a);
        }
예제 #2
0
        private void EndReceive(IAsyncResult res)
        {
            if (!working)
            {
                return;
            }
            args a = (args)res.AsyncState;
            int  k = a.s.EndReceive(res);

            a.cnt += k;
            for (int i = 0; i < k && i < a.buffer.Length; i++)
            {
                a.data.Add(a.buffer[i]);
            }
            byte[] data = CheckBuffer(a.data);
            if (data == null)
            {
                a.s.BeginReceive(a.buffer, 0, a.buffer.Length, SocketFlags.None,
                                 EndReceive, a);
            }
            else
            {
                ProcessData(data, a);
            }
        }
예제 #3
0
        private void backgroundWorker1_ProgressChanged(object sender, ProgressChangedEventArgs e)
        {
            args arg = (args)e.UserState;
            var  row = dataSetHistogram.tabKeywords.FindByKeyword(arg.keyword);

            if (row == null)
            {
                row         = dataSetHistogram.tabKeywords.NewtabKeywordsRow();
                row.Keyword = arg.keyword;
                dataSetHistogram.tabKeywords.AddtabKeywordsRow(row);
            }

            row.BeginEdit();
            row.Keyword = arg.keyword;

            string cat2 = arg.category;

            if (cat2.Contains(" "))
            {
                string[] xx = cat2.Split(' ');
                cat2 = xx[0];
            }
            cat2 = cat2 + "Hits";
            if (row.Table.Columns.Contains(cat2))
            {
                row[cat2] = (int)row[cat2] + 1;
            }
            else
            {
                System.Diagnostics.Debug.WriteLine("Booh");
            }

            row.EndEdit();
            row.AcceptChanges();
        }
예제 #4
0
        private static void HandleThread(object args)
        {
            args typedargs = args as args;

            log.DebugFormat("Thread started for {0}, code: {1}", typedargs.site, typedargs.code);
            var price = GetPrice(typedargs.site, typedargs.code, typedargs.article);

            log.DebugFormat("Thread done for {0}, code: {1}, price: {2}", typedargs.site, typedargs.code, price);
            threads[typedargs.index] = null;
            stopWaitHandle.Set();
        }
        private void hdMsgBytes(object oArgs)
        {
            args ar  = oArgs as args;
            var  msg = MessageExt.GetMessage(ar.bytes);

            if (msg != null)
            {
                if (msg.MessageGuid != null && msg.MessageGuid != "")
                {
                    Message tmpMsg;
                    if (dicSendedMessages.TryRemove(msg.MessageGuid, out tmpMsg))
                    {
                        dicRevivedMessages.TryAdd(msg.MessageGuid, msg);
                    }
                }
                this.HandleMessage?.BeginInvoke(this, ar.connID, msg, null, null);
            }
        }
        static string Ps2String(Type type, ParameterInfo[] ps, bool hasExtensionAttribute = false)
        {
            args f_args = new args();

            for (int j = 0; j < ps.Length; j++)
            {
                ParameterInfo p = ps[j];
                string        s = "";
                if (j == 0 && hasExtensionAttribute)
                {
                    s += "this ";
                }
                if (p.ParameterType.IsByRef)
                {
                    if (p.IsOut)
                    {
                        s += "out ";
                    }
                    else
                    {
                        s += "ref ";
                    }
                }
                if (ParameterIsParams(p))
                {
                    s += "params ";
                }
                s += typefn(p.ParameterType, p.ParameterType.DeclaringType == type ? "no-namespace" : type.Namespace, CsNameOption.CompilableWithT) + " ";
                s += p.Name;

                if (ParamHasDefaultValue(p))
                {
                    string ds = ParamDefaultValue2String(p);
                    s += " = " + ds;
                }

                f_args.Add(s);
            }
            ;
            return(f_args.ToString());
        }
예제 #7
0
        private void ws_MessageReceived(object sender, MessageReceivedEventArgs e)
        {
            if ("1::" == e.Message)
            {
                join();
            }

            if ("2::" == e.Message)
            {
                pong();
            }


            //5:::{"name":"message","args":["{\"method\":\"chatMsg\",\
            //"params\":{\"channel\":\"yuuhi\",\"name\":\"Slagator\",\"nameColor\":\"8051C7\",
            //\"text\":\"Uwaga Mikihashi zrzucil atomowke. xD\",\"time\":1441908923,
            //\"role\":\"anon\",\"isFollower\":true,\"isSubscriber\":true,\"isOwner\":false,
            //\"isStaff\":false,\"isCommunity\":false,\"media\":false,
            //\"image\":\"/static/img/chat/yuuhi/badge.png\"}}"]}

            try {
                if (e.Message.StartsWith("5:::"))
                {
                    message m = JsonConvert.DeserializeObject <message>(e.Message.Substring(4));
                    if (m.argsarray.Length > 0)
                    {
                        args a = JsonConvert.DeserializeObject <args>(m.argsarray[0]);
                        this.Status = true;

                        if (a.method == "chatMsg")
                        {
                            addMessage(a.prms);
                        }
                    }
                }
            }catch (Exception er) {
                App.Log('!', "hitbox: Json parse error: {0}", er);
            }

            Console.WriteLine(e.Message);
        }
예제 #8
0
 private void EndAcceptSocket(IAsyncResult res)
 {
     if (!working)
     {
         return;
     }
     try
     {
         args a = new args();
         a.s             = listener.EndAcceptSocket(res);
         a.buffer        = new byte[byte.MaxValue];
         a.cnt           = 0;
         a.data          = new List <byte>();
         a.T             = new System.Timers.Timer(TIMEOUT);
         a.T.AutoReset   = false;
         a.timerElapsed += new args.timerElapsedHandler(a_timerElapsed);
         a.s.BeginReceive(a.buffer, 0, a.buffer.Length, SocketFlags.None,
                          EndReceive, a);
     }
     finally { listener.BeginAcceptSocket(EndAcceptSocket, null); }
 }
예제 #9
0
        private void sendError(args a)
        {
            string      msg = CommandStart + "=ERR;" + CommandEnd;
            List <byte> pck = new List <byte>();

            pck.Add(CommandPr);
            foreach (byte b in Encoding.UTF8.GetBytes(msg))
            {
                pck.Add(b);
            }
            pck.Add(CommandTail);
            a.cnt = 0;
            a.data.Clear();
            a.buffer = pck.ToArray();
            try
            {
                if (working)
                {
                    a.s.BeginSend(a.buffer, 0, a.buffer.Length, SocketFlags.None,
                                  EndSend, a);
                }
            }
            catch { }
        }
예제 #10
0
 JoinPrint(args, work, (_) => joinString);
예제 #11
0
 Construct(args: values.ToArray <object?>());
예제 #12
0
 Console.SetIn(new StreamReader(args[0]));
예제 #13
0
    private static bool CompileJsCode(string allInvokeOutputPath, string allInvokeWithLocationOutputPath,
                                      string YieldReturnTypeOutputPath)
    {
        string workingDir = Application.dataPath.Replace("/Assets", "");

        var args = new args();

        // working dir
        args.AddFormat("/dir:\"{0}\"", workingDir);

        // define
        string define = "TRACE";

#if UNITY_ANDROID
        define += ";UNITY_ANDROID";
#endif

#if UNITY_IPHONE
        define += ";UNITY_IPHONE";
#endif

#if UNITY_4_6
        define += ";UNITY_4_6";
#endif

#if UNITY_4_7
        define += ";UNITY_4_7";
#endif

#if UNITY_4_8
        define += ";UNITY_4_8";
#endif

#if UNITY_5_0
        define += ";UNITY_5_0";
#endif

#if UNITY_5_1
        define += ";UNITY_5_1";
#endif

#if UNITY_5_2
        define += ";UNITY_5_2";
#endif

#if UNITY_5_3
        define += ";UNITY_5_3";
#endif
        //在这里可以加入自定义宏
#if UNITY_ANDROID
        string scriptDefines = PlayerSettings.GetScriptingDefineSymbolsForGroup(BuildTargetGroup.Android);
#elif UNITY_IPHONE
        string scriptDefines = PlayerSettings.GetScriptingDefineSymbolsForGroup(BuildTargetGroup.iPhone);
#else
        string scriptDefines = PlayerSettings.GetScriptingDefineSymbolsForGroup(BuildTargetGroup.Standalone);
#endif
        define += ";" + scriptDefines;
        if (!scriptDefines.Contains("ENABLE_JSB"))
        {
            define += ";ENABLE_JSB";
        }

        if (_editorDefine)
        {
            define += ";UNITY_EDITOR";
        }

        args.AddFormat("/define:{0}", define);

        if (_rebuild)
        {
            args.Add("/rebuild");
        }

        // references
        var assemblies = AppDomain.CurrentDomain.GetAssemblies();

        for (int i = 0; i < assemblies.Length; i++)
        {
            var asm = assemblies[i];
            args.AddFormat("/reference:\"{0}\"", asm.Location);
        }

        // out, target, target framework version
        args.Add("/out:" + ouputDllPath);
        args.Add("/target:library");
        args.Add("/TargetFrameworkVersion:v3.5");
        args.AddFormat("/AllInvocationsOutput:\"{0}\"", allInvokeOutputPath);
        args.AddFormat("/AllInvocationsWithLocationOutput:\"{0}\"", allInvokeWithLocationOutputPath);
        args.AddFormat("/YieldReturnTypeOutput:\"{0}\"", YieldReturnTypeOutputPath);
#if USE_SHELL
        args.Add("/exitReadKey");
#endif

        // source files
        var sources = Directory.GetFiles(Application.dataPath, "*.cs", SearchOption.AllDirectories);
        for (int i = 0; i < sources.Length; i++)
        {
            //Ignore Editor Folder *.cs files
            string filePath = sources[i].Replace('\\', '/');
            if (filePath.Contains("/WebPlayerTemplates"))
            {
                continue;
            }
            if (filePath.Contains("/Editor") && !filePath.EndsWith("JsTypeInfo.cs"))
            {
                continue;
            }

            args.Add("\"" + filePath.Replace(workingDir, ".") + "\"");
        }

        // 把参数写到文件中,然后把这个文件路径做为参数传递给 skc5.exe
        string argFile = GetTempFileNameFullPath("skc_args.txt");
        string strArgs = args.Format(args.ArgsFormat.Space);
        File.WriteAllText(argFile, strArgs);

        //windows下直接调用skc5编译,mac下需要通过mono调用skc5
#if UNITY_EDITOR_WIN
        string exePath   = Path.Combine(workingDir, JsCompilerPath);
        string arguments = String.Format("/paramFile:\"{0}\"", argFile);
#else
        string exePath   = "/usr/local/bin/mono";
        string arguments = Path.Combine(workingDir, JsCompilerPath) + string.Format(" /paramFile:\"{0}\"", argFile);
#endif
        var processInfo = new ProcessStartInfo
        {
#if USE_SHELL
            CreateNoWindow         = true,
            UseShellExecute        = true,
            RedirectStandardOutput = false,
            RedirectStandardError  = false,
            FileName  = exePath,
            Arguments = arguments
#else
            CreateNoWindow         = true,
            UseShellExecute        = false,
            RedirectStandardOutput = true,
            RedirectStandardError  = true,
            FileName  = exePath,
            Arguments = arguments
#endif
        };

        var process = Process.Start(processInfo);
#if !USE_SHELL
        string outputLog = process.StandardOutput.ReadToEnd();
        string errorLog  = process.StandardError.ReadToEnd();
#endif
        // 等待结束
        process.WaitForExit();

        int exitCode = process.ExitCode;
        process.Close();
        if (exitCode != 0)
        {
            EditorUtility.DisplayDialog("SharpKitCompiler", "Compile failed. exit code = " + exitCode, "OK");
#if !USE_SHELL
            Debug.LogError(outputLog);
            if (!string.IsNullOrEmpty(errorLog))
            {
                Debug.LogError(errorLog);
            }
#endif
            return(false);
        }

#if !USE_SHELL
        Debug.LogError(outputLog);
#endif
        EditorUtility.DisplayDialog("SharpKitCompiler", "Compile success.", "OK");
        return(true);
    }
 => AggregateLogicalExpression(args, boolResultType, Expression.OrElse, negate: true),
예제 #15
0
 if (true.Equals(args.NewValue))
 {
     ((CloseEnable)sender).Close();
예제 #16
0
 var(args, stack) = e;
예제 #17
0
파일: ConArgs.cs 프로젝트: ruialexrib/Ink
 public ConArgs(string[] args, params string[] keyStarts) => Constructor(args, keyStarts);
        protected override void onCreate(Bundle savedInstanceState)
        {
            Console.WriteLine("enter OVROculus360Photos ApplicationActivity onCreate");

            base.onCreate(savedInstanceState);




            Console.WriteLine("about to convince NDK what the first image should be...");
            // http://www.flightradar24.com/18.39,37.3/2

            // http://paulbourke.net/geometry/transformationprojection/

            // http://krpano.com/download/
            // http://unrealoldfriends.activeboard.com/t47250341/creating-background-using-spacescape/?page=1

            //Convert CUBE to SPHERE droplet


            //kcube2sphere 1.18.4 - 64bit (build 2015-04-23)
            //loading...
            //loading azi_l.jpg...
            //loading azi_f.jpg...
            //loading azi_r.jpg...
            //loading azi_b.jpg...
            //loading azi_u.jpg...
            //loading azi_d.jpg...
            //done.
            //making sphere azi_sphere.tif...
            //done.

            //Press any key to continue . . .










            //C:\Windows\system32> x:\util\android-sdk-windows\platform-tools\adb.exe push X:\jsc.svn\examples\javascript\synergy\css\CSSAzimuthMapViz\CSSAzimuthMapViz\Textures  /sdcard/oculus/360Photos/
            //push: X:\jsc.svn\examples\javascript\synergy\css\CSSAzimuthMapViz\CSSAzimuthMapViz\Textures/azi_pz.jpg -> /sdcard/oculus/360Photos/azi_pz.jpg
            //push: X:\jsc.svn\examples\javascript\synergy\css\CSSAzimuthMapViz\CSSAzimuthMapViz\Textures/azi_py.jpg -> /sdcard/oculus/360Photos/azi_py.jpg
            //push: X:\jsc.svn\examples\javascript\synergy\css\CSSAzimuthMapViz\CSSAzimuthMapViz\Textures/azi_px.jpg -> /sdcard/oculus/360Photos/azi_px.jpg
            //push: X:\jsc.svn\examples\javascript\synergy\css\CSSAzimuthMapViz\CSSAzimuthMapViz\Textures/azi_nz.jpg -> /sdcard/oculus/360Photos/azi_nz.jpg
            //push: X:\jsc.svn\examples\javascript\synergy\css\CSSAzimuthMapViz\CSSAzimuthMapViz\Textures/azi_ny.jpg -> /sdcard/oculus/360Photos/azi_ny.jpg
            //push: X:\jsc.svn\examples\javascript\synergy\css\CSSAzimuthMapViz\CSSAzimuthMapViz\Textures/azi_nx.jpg -> /sdcard/oculus/360Photos/azi_nx.jpg
            //6 files pushed. 0 files skipped.
            //466 KB/s (969865 bytes in 2.030s)

            //C:\Windows\system32> x:\util\android-sdk-windows\platform-tools\adb.exe shell cp /sdcard/oculus/360Photos/humus.thm /sdcard/oculus/360Photos/azi.thm

            Action<string, string> copy =
                (from, to) =>
                {

                    try
                    {

                        // http://gis.stackexchange.com/questions/92907/re-project-raster-image-from-mercator-to-equirectangular

                        // https://en.wikipedia.org/wiki/List_of_map_projections
                        // Web Mercator
                        // https://xkcd.com/977/
                        // mercator?
                        var value = this.getResources().getAssets().open(from);
                        var s = new __NetworkStream { InternalInputStream = value };

                        // 1,392,914
                        //var buffer = new byte[1392914];
                        var buffer = new byte[4392914];

                        var len = s.Read(buffer, 0, buffer.Length);


                        var m = new MemoryStream();

                        m.Write(buffer, 0, len);

                        //s.CopyTo(

                        File.WriteAllBytes(to, m.ToArray());

                    }
                    catch
                    {
                        Console.WriteLine("about to convince NDK what the first image should be... fault");

                    }

                };

            // https://sites.google.com/a/jsc-solutions.net/work/knowledge-base/15-dualvr/20150807/ovroculus360photosndk
            copy("2_no_clouds_4k.jpg", "/sdcard/oculus/360Photos/0.jpg");
            //copy("1.jpg", "/sdcard/oculus/360Photos/1.jpg");



            // https://sites.google.com/a/jsc-solutions.net/work/knowledge-base/15-dualvr/20150724/invaders
            //copy("celestial-joshua-trees-milky-way-in-saline-va.jpg", "/sdcard/oculus/360Photos/2.jpg");


            //Implementation not found for type import :
            //type: System.IO.DirectoryInfo
            //method: System.IO.FileInfo[] GetFiles()
            //Did you forget to add the [Script] attribute?
            //Please double check the signature!

            //Path.get

            var emptyFiles =
                from pf in new DirectoryInfo("/sdcard/oculus/360Photos/").GetFiles()
                where pf.Extension.ToLower() == ".jpg"
                where pf.Length == 0
                select pf;

            foreach (var emptyFile in emptyFiles.ToArray())
            {
                Console.WriteLine(new { emptyFile });

                emptyFile.Delete();
            }


            Console.WriteLine("about to convince NDK what the first image should be... done");


            var intent = getIntent();
            var commandString = com.oculus.vrappframework.VrActivity.getCommandStringFromIntent(intent);
            var fromPackageNameString = com.oculus.vrappframework.VrActivity.getPackageStringFromIntent(intent);
            var uriString = com.oculus.vrappframework.VrActivity.getUriStringFromIntent(intent);

            // D/CrashAnrDetector( 3472):     #00 pc 00092ac0  /data/app/OVROculus360Photos.Activities-1/lib/arm/libmain.so (OVR::ovrMessageQueue::PostMessage(char const*, bool, bool)+8)


            // https://sites.google.com/a/jsc-solutions.net/work/knowledge-base/15-dualvr/20160103/oculus360photossdk
            this.appPtr = OVROculus360Photos.Activities.xMarshal.nativeSetAppInterface(
                this,
                fromPackageNameString,
                commandString,
                uriString
            );

            var args = new args
            {

            };

            var uploadLength = 0L;
            var uploadPosition = 0L;

            var sw = Stopwatch.StartNew();

            #region mDraw
            var mDraw = new DrawOnTop(this)
            {
                // yes it appears top left.

                //text = "GearVR HUD"
                text = () => sw.ElapsedMilliseconds + "ms "
                    //+ "\n " + Path.GetFileName(args.filename)
                    + "\n " + args.filename

                    + "\n " + new
                    {
                        upload = (int)(100 * (uploadPosition + 1) / (args.filesize + 1)) + "%",
                        uploadPosition,
                        args.filesize,

                        // can we capture pointer?

                        args.x,
                        args.y,
                        args.z,

                        //uploadLength
                    }.ToString().Replace(",", ",\n")

                // X:\jsc.svn\examples\javascript\chrome\apps\WebGL\ChromeEquirectangularPanorama\ChromeEquirectangularPanorama\Application.cs
            };
            #endregion


            //Task.Run(

            #region sendTracking
            Action<IPAddress> sendTracking = nic =>
            {
                var port = new Random().Next(16000, 40000);

                //new IHTMLPre { "about to bind... " + new { port } }.AttachToDocument();

                // where is bind async?
                var socket = new UdpClient(
                     new IPEndPoint(nic, port)
                    );


                // who is on the other end?
                var nmessage = args.x + ":" + args.y + ":" + args.z + ":0:" + args.filename;

                var data = Encoding.UTF8.GetBytes(nmessage);      //creates a variable b of type byte


                //new IHTMLPre { "about to send... " + new { data.Length } }.AttachToDocument();

                // X:\jsc.svn\examples\javascript\chrome\apps\ChromeUDPNotification\ChromeUDPNotification\Application.cs
                //Console.WriteLine("about to Send");
                // X:\jsc.svn\examples\javascript\chrome\apps\WebGL\ChromeEquirectangularPanorama\ChromeEquirectangularPanorama\Application.cs
                socket.Send(
                     data,
                     data.Length,
                     hostname: "239.1.2.3",
                     port: 49834
                 );



                socket.Close();

            };
            #endregion




            //I/System.Console( 9109): 2395:1fb3 enter __UdpClient ctor
            //I/System.Console( 9109): 2395:1fb3 enter __UdpClient before this.Client
            //I/System.Console( 9109): 2395:1fb3 enter __UdpClient after this.Client { Client = ScriptCoreLibJava.BCLImplementation.System.Net.Sockets.__Socket@4f1c02b }
            //I/System.Console( 9109): 2395:1fb3 enter GetAllNetworkInterfaces
            //I/System.Console( 9109): 2395:1fb3 enter __UdpClient ctor

            string current = null;
            byte[] bytes = null;

            new Thread(
                delegate()
                {
                    // bg thread


                    // bug out 1sec.
                    Thread.Sleep(1000);
                    // await gear on

                    while (true)
                    {
                        // collect tracking from ndk
                        // broadcast to udp


                        //Thread.Sleep(1000 / 15);

                        //var a = new
                        //{
                        //    // for java do we also do the fields?
                        //    x = 0
                        //};

                        args.filename = OVROculus360Photos.Activities.xMarshal.stringFromJNI(args);

                        //E/AndroidRuntime( 7601): Caused by: java.lang.NullPointerException: Attempt to invoke virtual method 'char[] java.lang.String.toCharArray()' on a null object reference
                        //E/AndroidRuntime( 7601):        at java.io.File.fixSlashes(File.java:185)
                        //E/AndroidRuntime( 7601):        at java.io.File.<init>(File.java:134)
                        //E/AndroidRuntime( 7601):        at ScriptCoreLibJava.BCLImplementation.System.IO.__File.Exists(__File.java:57)
                        //E/AndroidRuntime( 7601):        at OVROculus360PhotosHUD.Activities.ApplicationActivity___c__DisplayClass1d._onCreate_b__1b(ApplicationActivity___c__DisplayClass1d.java:95)



                        // uplink 144Mbps
                        // 18 MBps
                        #region udp broadcast
                        // overkill at 60hz
                        NetworkInterface.GetAllNetworkInterfaces().WithEach(
                             n =>
                             {
                                 // X:\jsc.svn\examples\java\android\forms\FormsUDPJoinGroup\FormsUDPJoinGroup\ApplicationControl.cs
                                 // X:\jsc.svn\core\ScriptCoreLibJava\BCLImplementation\System\Net\NetworkInformation\NetworkInterface.cs

                                 var IPProperties = n.GetIPProperties();
                                 var PhysicalAddress = n.GetPhysicalAddress();



                                 foreach (var ip in IPProperties.UnicastAddresses)
                                 {
                                     // ipv4
                                     if (ip.Address.AddressFamily == System.Net.Sockets.AddressFamily.InterNetwork)
                                     {
                                         if (!IPAddress.IsLoopback(ip.Address))
                                             if (n.SupportsMulticast)
                                             {
                                                 //fWASDC(ip.Address);
                                                 //fParallax(ip.Address);
                                                 //fvertexTransform(ip.Address);
                                                 sendTracking(ip.Address);
                                             }
                                     }
                                 }




                             }
                         );



                        #endregion

                        if (args.filename != null)
                            if (File.Exists(args.filename))
                            {
                                if (current != args.filename)
                                {
                                    current = args.filename;

                                    var ff = new FileInfo(args.filename);

                                    args.filesize = ff.Length;

                                    // we are not on ui thread.
                                    // HUD thread can freeze...
                                    // mmap?
                                    bytes = File.ReadAllBytes(args.filename);

                                    // now broadcast. at 500KBps in segments.
                                    // 8MB is 16 segments then.

                                    if (bytes.Length > 0)
                                        NetworkInterface.GetAllNetworkInterfaces().WithEach(
                                              n =>
                                              {
                                                  // X:\jsc.svn\examples\java\android\forms\FormsUDPJoinGroup\FormsUDPJoinGroup\ApplicationControl.cs
                                                  // X:\jsc.svn\core\ScriptCoreLibJava\BCLImplementation\System\Net\NetworkInformation\NetworkInterface.cs

                                                  var IPProperties = n.GetIPProperties();
                                                  var PhysicalAddress = n.GetPhysicalAddress();



                                                  foreach (var ip in IPProperties.UnicastAddresses)
                                                  {
                                                      // ipv4
                                                      if (ip.Address.AddressFamily == System.Net.Sockets.AddressFamily.InterNetwork)
                                                      {
                                                          if (!IPAddress.IsLoopback(ip.Address))
                                                              if (n.SupportsMulticast)
                                                              {
                                                                  //fWASDC(ip.Address);
                                                                  //fParallax(ip.Address);
                                                                  //fvertexTransform(ip.Address);
                                                                  //sendTracking(ip.Address);

                                                                  var port = new Random().Next(16000, 40000);

                                                                  //new IHTMLPre { "about to bind... " + new { port } }.AttachToDocument();

                                                                  // where is bind async?
                                                                  var socket = new UdpClient(
                                                                       new IPEndPoint(ip.Address, port)
                                                                      );


                                                                  //// who is on the other end?
                                                                  //var nmessage = args.x + ":" + args.y + ":" + args.z + ":0:" + args.filename;

                                                                  //var data = Encoding.UTF8.GetBytes(nmessage);      //creates a variable b of type byte

                                                                  // http://stackoverflow.com/questions/25841/maximum-buffer-length-for-sendto

                                                                  new { }.With(
                                                                      async delegate
                                                                      {
                                                                          // reached too far?
                                                                          if (bytes.Length == 0)
                                                                              return;

                                                                          var current0 = current;

                                                                          var r = new MemoryStream(bytes);
                                                                          uploadLength = r.Length;

                                                                          var data = new byte[65507];

                                                                      next:

                                                                          if (current0 != current)
                                                                              return;

                                                                          var cc = r.Read(data, 0, data.Length);

                                                                          uploadPosition = r.Position;

                                                                          if (cc <= 0)
                                                                              return;

                                                                          //new IHTMLPre { "about to send... " + new { data.Length } }.AttachToDocument();

                                                                          // X:\jsc.svn\examples\javascript\chrome\apps\ChromeUDPNotification\ChromeUDPNotification\Application.cs
                                                                          //Console.WriteLine("about to Send");
                                                                          // X:\jsc.svn\examples\javascript\chrome\apps\WebGL\ChromeEquirectangularPanorama\ChromeEquirectangularPanorama\Application.cs
                                                                          await socket.SendAsync(
                                                                               data,
                                                                               cc,
                                                                               hostname: "239.1.2.3",
                                                                               port: 49000
                                                                           );

                                                                          //await Task.Delay(1000 / 15);
                                                                          //await Task.Delay(1000 / 30);

                                                                          // no corruption
                                                                          await Task.Delay(1000 / 20);

                                                                          goto next;

                                                                      }
                                                                  );

                                                                  //socket.Close();
                                                              }
                                                      }
                                                  }




                                              }
                                          );
                                }
                            }

                        if (uploadPosition < args.filesize)
                            mDraw.color = android.graphics.Color.YELLOW;
                        else
                            mDraw.color = android.graphics.Color.GREEN;

                        mDraw.postInvalidate();
                        Thread.Sleep(1000 / 30);
                        //Thread.Sleep(1000 / 2);
                        //Thread.Sleep(1000 / 15);
                    }
                }
            ).Start();

            //this.ondispatchTouchEvent += @event =>
            //{

            //    int action = @event.getAction();
            //    float x = @event.getRawX();
            //    float y = @event.getRawY();
            //    //if (action == MotionEvent.ACTION_UP)
            //    {
            //        var halfx = 2560 / 2;
            //        var halfy = 1440 / 2;

            //        mDraw.x = (int)(500 + halfx - x);
            //        mDraw.y = (int)(600 + y - halfy);
            //        mDraw.text = () => sw.ElapsedMilliseconds + "ms \n" + new { x, y, action }.ToString();
            //        //Console.WriteLine(" ::dispatchTouchEvent( " + action + ", " + x + ", " + y + " )");
            //    }

            //    // can we move hud around and record it to gif or mp4?

            //    return true;
            //};

            // X:\jsc.svn\examples\java\android\synergy\OVRVrCubeWorldSurfaceView\OVRVrCubeWorldSurfaceView\ApplicationActivity.cs
            // X:\jsc.svn\examples\java\android\AndroidLacasCameraServerActivity\AndroidLacasCameraServerActivity\ApplicationActivity.cs
            addContentView(mDraw, new ViewGroup.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT));


            // "x:\util\android-sdk-windows\platform-tools\adb.exe" connect 192.168.1.126:5555
            // cmd /K x:\util\android-sdk-windows\platform-tools\adb.exe logcat -s "JniUtils"  "System.Console" "art"


            // E/JniUtils(14136): couldn't get isHybridApp, (Landroid/app/Activity;)Z

            //            I/Oculus360Photos( 9199): nativeSetAppInterface
            //I/App     ( 9199): VrAppInterface::SetActivity:
            //I/App     ( 9199): new AppLocal( 0xf51512b0 0xff8b6b80 0xeef69900 )
            //I/App     ( 9199): ----------------- AppLocal::AppLocal() -----------------
            //E/JniUtils( 9199): couldn't get getInternalCacheMemoryInBytes, (Landroid/app/Activity;)J

            //            I/JniUtils(26390): Using caller's JNIEnv
            //E/JniUtils(26390): couldn't get getInstalledPackagePath, (Ljava/lang/String;)Ljava/lang/String;

            //            I/System.Console( 3652): 0e44:0001 Searching installed packages for 'com.oculus.systemactivities'
            //I/JniUtils( 3652): ovr_GetCurrentPackageName() = OVROculus360PhotosHUD.Activities
            //I/JniUtils( 3652): ovr_GetPackageCodePath() = '/data/app/OVROculus360PhotosHUD.Activities-1/base.apk'
            //W/art     ( 3652): Attempt to remove local handle scope entry from IRT, ignoring
            //W/art     ( 3652): Attempt to remove local handle scope entry from IRT, ignoring
            //W/art     ( 3652): Attempt to remove local handle scope entry from IRT, ignoring
            //I/JniUtils( 3652): ovr_GetCurrentActivityName() = OVROculus360PhotosHUD.Activities.ApplicationActivity
            //I/JniUtils( 3652): ovr_GetCurrentPackageName() = OVROculus360PhotosHUD.Activities
            //E/JniUtils( 3652): couldn't get getLocalizedString, (Ljava/lang/String;)Ljava/lang/String;
            //I/JniUtils( 4380): ovr_GetCurrentActivityName() = com.oculus.home.HomeActivity

            // ffs
        }
 ? GetArgValue(args[paramIndex])
 : AttributeValue.BAD_VALUE;
        static void GenInterfaceOrStructOrClass(Type type, TypeStatus ts,
                                                Func <Type, TypeStatus> getParent, Action <Type> onNewType)
        {
            TextFile tfFile = null;

            if (type.DeclaringType != null)
            {
                ts.IsInnerType = true;

                TypeStatus tsParent = getParent(type.DeclaringType);
                if (tsParent == null || tsParent.status == TypeStatus.Status.Wait)
                {
                    if (tsParent == null)
                    {
                        onNewType(type.DeclaringType);
                    }
                    return;
                }

                if (tsParent.status == TypeStatus.Status.Ignored)
                {
                    ts.status = TypeStatus.Status.Ignored;
                    return;
                }

                tfFile = tsParent.tf.FindByTag("epos");
            }

            if (tfFile == null)
            {
                tfFile = new TextFile();
            }

            ts.tf     = tfFile;
            ts.status = TypeStatus.Status.Exported;

            GeneratorHelp.ATypeInfo ti = GeneratorHelp.CreateTypeInfo(type);

            StringBuilder sb   = new StringBuilder();
            TextFile      tfNs = tfFile;

            //string dir = Dir;

            // // ignore Experimental @eugenejiang
            // if (type.Namespace != null && type.Namespace.IndexOf("UnityEngine.Experimental.") >= 0) {
            //  return;
            // }
            if (type.DeclaringType == null &&
                !string.IsNullOrEmpty(type.Namespace))
            {
                tfNs = tfFile.Add("namespace {0}", type.Namespace).BraceIn();
                tfNs.BraceOut();
            }

            GenAttributeForClassIfNeeded(type, tfNs);

            // multiple attributes

//            tfNs.Add("[Bridge.External]");
            TextFile tfClass = null;

            sb.Remove(0, sb.Length);
            {
                // force public
                if (type.IsPublic || type.IsNestedPublic || type.IsNested || type.IsNestedFamily)
                {
                    sb.Append("public ");
                }

                // if (type.IsNestedFamily) {
                //     sb.Append("protected ");
                // }

                // if (type.FullName.IndexOf("DropdownItem") >= 0) {
                //  Debug.Assert(false);
                // }

                if (type.IsClass)
                {
                    if (type.IsAbstract && type.IsSealed)
                    {
                        sb.Append("static ");
                    }
                    //else if (type.IsAbstract)
                    //    sb.Append("abstract ");
                    //else if (type.IsSealed)
                    //    sb.Append("sealed ");

                    //if (type.is)
                }

                if (type.IsInterface)
                {
                    sb.Append("interface ");
                }
                else if (type.IsValueType)
                {
                    sb.Append("struct ");
                }
                else
                {
                    sb.Append("class ");
                }

                string className = type.CsFullName(CsNameOption.CompilableWithT);
                int    dot       = className.LastIndexOf(".");
                if (dot >= 0)
                {
                    className = className.Substring(dot + 1);
                }
                sb.Append(className);

                Type   vBaseType  = type.ValidBaseType();
                Type[] interfaces = type.GetDeclaringInterfaces();
                if (vBaseType != null || interfaces.Length > 0)
                {
                    sb.Append(" : ");

                    args a = new args();
                    if (vBaseType != null)
                    {
                        a.Add(typefn(vBaseType, type.Namespace, CsNameOption.CompilableWithT));
                        onNewType(vBaseType);
                    }
                    foreach (var i in interfaces)
                    {
                        a.Add(typefn(i, type.Namespace, CsNameOption.CompilableWithT));
                        onNewType(i);
                    }

                    sb.Append(a.ToString());
                }

                tfClass = tfNs.Add(sb.ToString()).BraceIn();
                tfClass.BraceOut();
            }

            tfClass.AddTag("epos");

            if (handleEvents(tfClass, type, onNewType))
            {
                tfClass.AddLine();
            }

            for (int i = 0; i < ti.Fields.Count; i++)
            {
                MemberInfoEx infoEx            = ti.Fields[i];
                FieldInfo    field             = infoEx.member as FieldInfo;
                var          publicOrProtected = "public";
                if (field.IsFamily)
                {
                    // publicOrProtected = "protected";
                }
                if (field.IsLiteral && !field.IsInitOnly)
                {
                    {
                        var attributes = field.GetCustomAttributes();
                        foreach (var attr in attributes)
                        {
                            tfClass.Add("[{0}]", attr.GetType().Name);
                            onNewType(attr.GetType());
                        }
                    }



                    if ("string" == typefn(field.FieldType, type.Namespace))
                    {
                        tfClass.Add(publicOrProtected + " const {0} {1} = \"{2}\";", typefn(field.FieldType, type.Namespace), field.Name, field.GetValue(null));
                    }
                    else if ("float" == typefn(field.FieldType, type.Namespace))
                    {
                        var    fv = (float)field.GetValue(null);
                        string defaultvalue;
                        if (float.IsNaN(fv))
                        {
                            defaultvalue = "float.NaN";
                        }
                        else if (float.IsPositiveInfinity(fv))
                        {
                            defaultvalue = "float.PositiveInfinity";
                        }
                        else if (float.IsNegativeInfinity(fv))
                        {
                            defaultvalue = "float.NegativeInfinity";
                        }
                        else
                        {
                            defaultvalue = fv + "f";
                        }
                        tfClass.Add(publicOrProtected + " const {0} {1} = {2};", typefn(field.FieldType, type.Namespace), field.Name, defaultvalue);
                    }
                    else
                    {
                        tfClass.Add(publicOrProtected + " const {0} {1} = {2};", typefn(field.FieldType, type.Namespace), field.Name, field.GetValue(null));
                    }
                }
                else
                {
                    tfClass.Add(publicOrProtected + " {0}{1} {2};", (field.IsStatic ? "static " : ""), typefn(field.FieldType, type.Namespace), field.Name);
                }

                onNewType(field.FieldType);
            }
            if (ti.Fields.Count > 0)
            {
                tfClass.AddLine();
            }

            // Constructors
            for (int i = 0; i < ti.Cons.Count; i++)
            {
                MemberInfoEx    infoEx = ti.Cons[i];
                ConstructorInfo con    = infoEx.member as ConstructorInfo;

                if (type.IsValueType)
                {
                    // 结构体不需要无参数构造函数
                    if (con == null || con.GetParameters().Length == 0)
                    {
                        continue;
                    }
                }

                string ctorName = type.Name;
                if (type.IsGenericTypeDefinition)
                {
                    int flag = ctorName.LastIndexOf('`');
                    if (flag >= 0)
                    {
                        ctorName = ctorName.Substring(0, flag);
                    }
                }

                var constructorBuilder = new StringBuilder();
                var paras = con == null ? "" : Ps2String(type, con.GetParameters());
                constructorBuilder.Append($"public {ctorName}({paras})");
                var baseType = type.ValidBaseType();
                if (baseType != null && !HasDefaultConstructor(baseType))
                {
                    constructorBuilder.Append($" : base({BaseConstructorParameters(baseType)})");
                }
                constructorBuilder.Append(" { throw new Exception(\"not impl\"); }");

                tfClass.Add(constructorBuilder.ToString());

                if (con != null)
                {
                    foreach (var p in con.GetParameters())
                    {
                        onNewType(p.ParameterType);
                    }
                }
            }
            if (ti.Cons.Count > 0)
            {
                tfClass.AddLine();
            }

            handlePros(tfClass, type, ti, onNewType);

            if (ti.Pros.Count > 0)
            {
                tfClass.AddLine();
            }

            handleMethods(tfClass, type, ti, onNewType);
            if (!type.IsInterface)
            {
                handleInterfaceProblems(tfClass, type, onNewType);
            }
        }
        static void handleMethods(TextFile tfClass, Type type, GeneratorHelp.ATypeInfo ti, Action <Type> OnNewType)
        {
            Action <MethodInfo> action = (method) =>
            {
                bool            hasExtensionAttribute = (method.GetCustomAttributes(typeof(System.Runtime.CompilerServices.ExtensionAttribute), false).Length > 0);
                ParameterInfo[] ps           = method.GetParameters();
                var             paramsString = Ps2String(type, ps, hasExtensionAttribute);
                // if (paramsString.IndexOf("UnityEngine.Experimental.") >= 0) {
                //  return;
                // }

                // ignore unsafe
                if (paramsString.IndexOf("*") >= 0)
                {
                    return;
                }

                // DO NOT handle Finalize method
                if (method.Name == "Finalize")
                {
                    return;
                }
                StringBuilder sbDef = new StringBuilder();

                bool isI = type.IsInterface;

                if (!isI)
                {
                    if (method.IsPublic)
                    {
                        sbDef.Append("public ");
                    }
                    else if (method.IsFamily)
                    {
                        sbDef.Append("public ");
                    }
                    // sbDef.Append("protected ");
                    else if (method.IsAssembly)
                    {
                        sbDef.Append("public ");
                    }
                    // sbDef.Append("internal ");

                    if (method.IsStatic)
                    {
                        sbDef.Append("static ");
                    }

//					sbDef.Append("extern ");

                    if (method.GetBaseDefinition() != method)
                    {
                        sbDef.Append("override ");
                    }
                    else if (!type.IsValueType && method.IsVirtual && !type.IsValueType)
                    {
                        sbDef.Append("virtual ");
                    }
                }

                if (!(method.IsSpecialName && method.Name == "op_Implicit"))
                {
                    sbDef.Append(typefn(method.ReturnType, type.Namespace, CsNameOption.CompilableWithT) + " ");
                }

                OnNewType(method.ReturnType);

                sbDef.Append(MethodNameString(type, method));

                if (method.IsGenericMethodDefinition)
                {
                    Type[] argus  = method.GetGenericArguments();
                    args   t_args = new args();
                    foreach (var a in argus)
                    {
                        t_args.Add(a.Name);
                    }

                    sbDef.Append(t_args.Format(args.ArgsFormat.GenericT));
                }

                sbDef.Append("(");
                // bool hasExtensionAttribute = (method.GetCustomAttributes(typeof(System.Runtime.CompilerServices.ExtensionAttribute), false).Length > 0);
                // ParameterInfo[] ps = method.GetParameters();
                {
                    sbDef.Append(Ps2String(type, ps, hasExtensionAttribute));
                    sbDef.Append(")");

                    foreach (var p in ps)
                    {
                        OnNewType(p.ParameterType);
                    }
                }
                sbDef.Append(!isI ? " { throw new Exception(\"not impl\"); }" : ";");
//				tfClass.Add("[Bridge.Name(\"" + method.Name + "\")]");
                tfClass.Add(sbDef.ToString());
            };

            bool hasSpecial = false;

            for (int i = 0; i < ti.Methods.Count; i++)
            {
                MemberInfoEx infoEx = ti.Methods[i];
                MethodInfo   method = infoEx.member as MethodInfo;
                if (method.IsSpecialName)
                {
                    hasSpecial = true;
                    action(method);
                }
            }

            if (hasSpecial)
            {
                tfClass.AddLine();
            }

            for (int i = 0; i < ti.Methods.Count; i++)
            {
                MemberInfoEx infoEx = ti.Methods[i];
                MethodInfo   method = infoEx.member as MethodInfo;

                if (!method.IsSpecialName)
                {
                    action(method);
                }
            }
        }
 void connection_ServerDisconnected(object sender, args.ServerEventArgs e)
 {
     //lo rimuova dalla lista sotto
     serverAggiunti.Remove(e.Server);
     //lo inserisce nella lista sopra
     if (!serverTrovati.Contains(e.Server))
     {
         serverTrovati.Add(e.Server);
     }
 }
예제 #23
0
파일: Zion.cs 프로젝트: jbnivoit/projects
 new Zion (args).exec ();
        void connection_ServerFound(object sender, args.ServerEventArgs e)
        {
            Console.WriteLine("server aggiunto");
            Server server = e.Server;

            if (!serverTrovati.Contains(e.Server))
            {
                serverTrovati.Add(server);
            }
        }
예제 #25
0
    public static void BuildConstructors(Type type, ConstructorInfo[] constructors, int slot,
                                         StringBuilder sbDefinition, List <string> memberNames)
    {
        var  argActual  = new args();
        var  argFormal  = new args();
        bool overloaded = constructors.Length > 1;

        for (int i = 0; i < constructors.Length; i++)
        {
            var con = constructors[i];
            var ps  = con == null ? new ParameterInfo[0] : con.GetParameters();

            argActual.Clear().Add(
                (int)JSVCall.Oper.CONSTRUCTOR, // OP
                slot,
                i,                             // NOTICE
                "true",                        // IsStatics
                "this"
                );

            argFormal.Clear();

            // add T to formal param
            if (type.IsGenericTypeDefinition)
            {
                // TODO check
                int TCount = type.GetGenericArguments().Length;
                for (int j = 0; j < TCount; j++)
                {
                    argFormal.Add("t" + j + "");
                    argActual.Add("t" + j + ".getNativeType()");
                }
            }

            for (int j = 0; j < ps.Length; j++)
            {
                argFormal.Add("a" + j);
                var par = ps[j];
                if (par.ParameterType == typeof(Type))
                {
                    //如果是System.Type类型参数需要传递其FullName回来
                    //在C#层通过JSDataExchangeMgr.GetTypeByName获取其类型对象
                    argActual.Add(string.Format("a{0}.get_FullName()", j));
                }
                else if (par.ParameterType.IsArray && par.ParameterType.GetElementType() == typeof(Type))
                {
                    //如果是System.Type类型数组参数,通过转换获取其类型全名数组
                    argActual.Add(string.Format("jsb_convertTypeParamsArray(a{0})", j));
                }
                else
                {
                    argActual.Add("a" + j);
                }
            }

            string ctorName = GetOverloadedMethodSuffix("ctor", ps, overloaded);
            memberNames.Add(ctorName);

            sbDefinition.AppendFormat(@"
        {0}: function({1}) [[ CS.Call({2}); ]],",
                                      ctorName,
                                      argFormal,
                                      argActual);
        }
    }
예제 #26
0
파일: cs1001.cs 프로젝트: nlhepler/mono
	// Change (args) to (string args) to fix it
	public static int Main (args)
	{
	}
예제 #27
0
 // 2. Create callback so that lib can verify credential id is unique to this user
 IsCredentialIdUniqueToUserAsyncDelegate callback = static async(args, cancellationToken) =>
 {
 => AggregateLogicalExpression(args, boolResultType, Expression.AndAlso, negate: true),
예제 #29
0
    public static void GenerateJsTypeInfo(bool displayDialog)
    {
        var    fileInfoSb = new StringBuilder();
        string workingDir = Application.dataPath.Replace("/Assets", "");
        var    args       = new args();

        // working dir
        args.AddFormat("/dir:\"{0}\"", workingDir);
        args.AddFormat("/out:\"{0}\"", JsTypeInfoFile);
        args.AddFormat("/template:\"{0}\"", JsTypeInfoFileTemplate);
        args.AddFormat("/format:\"{0}\"", JsTypeFormat);

        var exportList  = GetExportFiles();
        var exportCount = exportList.Count;

        foreach (var filePath in exportList)
        {
            fileInfoSb.AppendLine(filePath.Replace(Application.dataPath, ""));
            args.Add("\"" + filePath.Replace(workingDir, ".") + "\"");
        }

        // 把参数写到文件中,然后把这个文件路径做为参数传递给 skc5.exe
        string argFile = GetTempFileNameFullPath("JsTypeGenerator_Args.txt");
        string strArgs = args.Format(args.ArgsFormat.Space);

        File.WriteAllText(argFile, strArgs);

        string addTypeInfoFile = GetTempFileNameFullPath(FilesToAddJsType);

        File.WriteAllText(addTypeInfoFile, fileInfoSb.ToString());
        AssetDatabase.Refresh();

        if (displayDialog)
        {
            if (!EditorUtility.DisplayDialog("TIP",
                                             "Total: " + exportCount + "file prepare to Add [JsType]",
                                             "OK",
                                             "Cancel"))
            {
                Debug.Log("Operation canceled.");
                return;
            }
        }

#if UNITY_EDITOR_WIN
        string exePath   = Path.Combine(workingDir, JsTypeGeneratorPath);
        string arguments = String.Format("/paramFile:\"{0}\"", argFile);
#else
        string exePath   = "/usr/local/bin/mono";
        string arguments = Path.Combine(workingDir, JsTypeGeneratorPath) + string.Format(" /paramFile:\"{0}\"", argFile);
#endif
        var processInfo = new ProcessStartInfo
        {
            CreateNoWindow         = true,
            UseShellExecute        = false,
            RedirectStandardOutput = true,
            RedirectStandardError  = true,
            FileName  = exePath,
            Arguments = arguments
        };

        var    process   = Process.Start(processInfo);
        string outputLog = process.StandardOutput.ReadToEnd();
        string errorLog  = process.StandardError.ReadToEnd();
        // 等待结束
        process.WaitForExit();

        Debug.LogError(outputLog);
        int exitCode = process.ExitCode;
        process.Close();
        if (exitCode != 0)
        {
            EditorUtility.DisplayDialog("JsTypeGenerator", "Generate failed. exit code = " + exitCode, "OK");
            if (!String.IsNullOrEmpty(errorLog))
            {
                Debug.LogError(errorLog);
            }
            throw new SystemException(errorLog);
        }

        //每次生成JsTypeInfo,清空一下JsTypeNameSet
        _jsTypeNameSet = null;
        if (displayDialog)
        {
            EditorUtility.DisplayDialog("JsTypeGenerator", "GenerateJsTypeInfo success.", "OK");
        }

        // 刷新前改一下文件格式,减少编译时间
        EditorHelper.SetFileFormatToUTF8_BOM(JsTypeInfoFile);

        AssetDatabase.SaveAssets();
        AssetDatabase.Refresh();
    }
예제 #30
0
 ParseWords(args, parseOptions).Select <string, (string, string?)>(word => {
예제 #31
0
    private static bool CompileJsCode(string allInvokeOutputPath, string allInvokeWithLocationOutputPath,
                                      string YieldReturnTypeOutputPath, bool displayDialog)
    {
        string workingDir = Application.dataPath.Replace("/Assets", "");

        var args = new args();

        // working dir
        args.AddFormat("/dir:\"{0}\"", workingDir);

        var define = GetDefines();

        args.AddFormat("/define:{0}", define);

        if (_rebuild)
        {
            args.Add("/rebuild");
        }

        // references
        foreach (var reference in GetReferences())
        {
            args.AddFormat("/reference:\"{0}\"", reference);
        }

        // out, target, target framework version
        args.Add("/out:" + ouputDllPath);
        args.Add("/target:library");
        args.Add("/TargetFrameworkVersion:v3.5");
        args.AddFormat("/AllInvocationsOutput:\"{0}\"", allInvokeOutputPath);
        args.AddFormat("/AllInvocationsWithLocationOutput:\"{0}\"", allInvokeWithLocationOutputPath);
        args.AddFormat("/YieldReturnTypeOutput:\"{0}\"", YieldReturnTypeOutputPath);
#if USE_SHELL
        args.Add("/exitReadKey");
#endif

        // source files
        foreach (var csFile in GetCsFiles())
        {
            args.Add("\"" + csFile.Replace(workingDir, ".") + "\"");
        }

        // 把参数写到文件中,然后把这个文件路径做为参数传递给 skc5.exe
        string argFile = GetTempFileNameFullPath("skc_args.txt");
        string strArgs = args.Format(args.ArgsFormat.Space);
        File.WriteAllText(argFile, strArgs);

        //windows下直接调用skc5编译,mac下需要通过mono调用skc5
#if UNITY_EDITOR_WIN
        string exePath   = Path.Combine(workingDir, JsCompilerPath);
        string arguments = String.Format("/paramFile:\"{0}\"", argFile);
#else
        string exePath   = "/usr/local/bin/mono";
        string arguments = Path.Combine(workingDir, JsCompilerPath) + string.Format(" /paramFile:\"{0}\"", argFile);
#endif
        var processInfo = new ProcessStartInfo
        {
#if USE_SHELL
            CreateNoWindow         = true,
            UseShellExecute        = true,
            RedirectStandardOutput = false,
            RedirectStandardError  = false,
            FileName  = exePath,
            Arguments = arguments
#else
            CreateNoWindow         = true,
            UseShellExecute        = false,
            RedirectStandardOutput = true,
            RedirectStandardError  = true,
            FileName  = exePath,
            Arguments = arguments
#endif
        };

        var process = Process.Start(processInfo);
#if !USE_SHELL
        string outputLog = process.StandardOutput.ReadToEnd();
        string errorLog  = process.StandardError.ReadToEnd();
#endif
        // 等待结束
        process.WaitForExit();

        int exitCode = process.ExitCode;
        process.Close();
        if (exitCode != 0)
        {
            if (displayDialog)
            {
                EditorUtility.DisplayDialog("SharpKitCompiler", "Compile failed. exit code = " + exitCode, "OK");
            }
#if !USE_SHELL
            Debug.LogError(outputLog + "just Log, 非Error (可以忽略)");
            if (!string.IsNullOrEmpty(errorLog))
            {
                Debug.LogError(errorLog);
            }

            File.WriteAllText("skcErr.txt", outputLog + "\n" + errorLog);
#endif

            return(false);
        }

#if !USE_SHELL
        Debug.LogError(outputLog);
#endif
        if (displayDialog)
        {
            EditorUtility.DisplayDialog("SharpKitCompiler", "Compile success.", "OK");
        }
        return(true);
    }
예제 #32
0
    public static void GenerateJsTypeInfo()
    {
        var    fileInfoSb = new StringBuilder();
        string workingDir = Application.dataPath.Replace("/Assets", "");
        var    args       = new args();

        // working dir
        args.AddFormat("/dir:\"{0}\"", workingDir);
        args.AddFormat("/out:\"{0}\"", JsTypeInfoFile);
        args.AddFormat("/template:\"{0}\"", JsTypeInfoFileTemplate);
        args.AddFormat("/format:\"{0}\"", JsTypeFormat);

        var csFiles     = Directory.GetFiles(Application.dataPath, "*.cs", SearchOption.AllDirectories);
        int exportCount = 0;

        // filter files
        for (int i = 0; i < csFiles.Length; i++)
        {
            string file     = csFiles[i];
            string filePath = file.Replace('\\', '/');
            bool   export   = false;

            //忽略Editor目录下的脚本
            if (filePath.Contains("Editor/"))
            {
                continue;
            }

            ////检查是否在忽略文件目录列表中
            //for (int j = 0; j < JSBCodeGenSettings.PathsNotToJavaScript.Length; j++)
            //{
            //    string dir = JSBCodeGenSettings.PathsNotToJavaScript[j];
            //    if (filePath.Contains(dir))
            //    {
            //        export = false;
            //        break;
            //    }
            //}

            //检查是否在指定文件目录列表中
            if (!export && JSBCodeGenSettings.PathsToJavaScript != null)
            {
                for (int k = 0; k < JSBCodeGenSettings.PathsToJavaScript.Length; k++)
                {
                    string dir = JSBCodeGenSettings.PathsToJavaScript[k];
                    if (filePath.Contains(dir))
                    {
                        export = true;
                        break;
                    }
                }
            }
            if (export)
            {
                exportCount++;
                fileInfoSb.AppendLine(filePath.Replace(Application.dataPath, ""));
                args.Add("\"" + filePath.Replace(workingDir, ".") + "\"");
            }
        }

        // 把参数写到文件中,然后把这个文件路径做为参数传递给 skc5.exe
        string argFile = GetTempFileNameFullPath("JsTypeGenerator_Args.txt");
        string strArgs = args.Format(args.ArgsFormat.Space);

        File.WriteAllText(argFile, strArgs);

        string addTypeInfoFile = GetTempFileNameFullPath(FilesToAddJsType);

        File.WriteAllText(addTypeInfoFile, fileInfoSb.ToString());
        AssetDatabase.Refresh();

        if (!EditorUtility.DisplayDialog("TIP",
                                         "Total: " + exportCount + "file prepare to Add [JsType]",
                                         "OK",
                                         "Cancel"))
        {
            Debug.Log("Operation canceled.");
            return;
        }

#if UNITY_EDITOR_WIN
        string exePath   = Path.Combine(workingDir, JsTypeGeneratorPath);
        string arguments = String.Format("/paramFile:\"{0}\"", argFile);
#else
        string exePath   = "/usr/local/bin/mono";
        string arguments = Path.Combine(workingDir, JsTypeGeneratorPath) + string.Format(" /paramFile:\"{0}\"", argFile);
#endif
        var processInfo = new ProcessStartInfo
        {
            CreateNoWindow         = true,
            UseShellExecute        = false,
            RedirectStandardOutput = true,
            RedirectStandardError  = true,
            FileName  = exePath,
            Arguments = arguments
        };

        var    process   = Process.Start(processInfo);
        string outputLog = process.StandardOutput.ReadToEnd();
        string errorLog  = process.StandardError.ReadToEnd();
        // 等待结束
        process.WaitForExit();

        Debug.LogError(outputLog);
        int exitCode = process.ExitCode;
        process.Close();
        if (exitCode != 0)
        {
            EditorUtility.DisplayDialog("JsTypeGenerator", "Generate failed. exit code = " + exitCode, "OK");
            if (!String.IsNullOrEmpty(errorLog))
            {
                Debug.LogError(errorLog);
            }

            return;
        }

        //每次生成JsTypeInfo,清空一下JsTypeNameSet
        _jsTypeNameSet = null;
        EditorUtility.DisplayDialog("JsTypeGenerator", "GenerateJsTypeInfo success.", "OK");
        AssetDatabase.Refresh();
    }
예제 #33
0
 MCDawn_.Gui.Program.Main(args);
 DrainHandling(args, notHandledArgs =>
 {
     switch (notHandledArgs.Item2)
 void connection_ServerConnected(object sender, args.ServerEventArgs e)
 {
     //lo rimuovo dalla lista dei server trovati(lista in alto)
     serverTrovati.Remove(e.Server);
     //lo aggiungo alla lista dei server connessi(lista in basso)
     serverAggiunti.Add(e.Server);
 }
        protected override void onCreate(Bundle savedInstanceState)
        {
            Console.WriteLine("enter OVROculus360Photos ApplicationActivity onCreate");

            base.onCreate(savedInstanceState);



            Console.WriteLine("about to convince NDK what the first image should be...");
            // http://www.flightradar24.com/18.39,37.3/2

            // http://paulbourke.net/geometry/transformationprojection/

            // http://krpano.com/download/
            // http://unrealoldfriends.activeboard.com/t47250341/creating-background-using-spacescape/?page=1

            //Convert CUBE to SPHERE droplet


            //kcube2sphere 1.18.4 - 64bit (build 2015-04-23)
            //loading...
            //loading azi_l.jpg...
            //loading azi_f.jpg...
            //loading azi_r.jpg...
            //loading azi_b.jpg...
            //loading azi_u.jpg...
            //loading azi_d.jpg...
            //done.
            //making sphere azi_sphere.tif...
            //done.

            //Press any key to continue . . .



            //C:\Windows\system32> x:\util\android-sdk-windows\platform-tools\adb.exe push X:\jsc.svn\examples\javascript\synergy\css\CSSAzimuthMapViz\CSSAzimuthMapViz\Textures  /sdcard/oculus/360Photos/
            //push: X:\jsc.svn\examples\javascript\synergy\css\CSSAzimuthMapViz\CSSAzimuthMapViz\Textures/azi_pz.jpg -> /sdcard/oculus/360Photos/azi_pz.jpg
            //push: X:\jsc.svn\examples\javascript\synergy\css\CSSAzimuthMapViz\CSSAzimuthMapViz\Textures/azi_py.jpg -> /sdcard/oculus/360Photos/azi_py.jpg
            //push: X:\jsc.svn\examples\javascript\synergy\css\CSSAzimuthMapViz\CSSAzimuthMapViz\Textures/azi_px.jpg -> /sdcard/oculus/360Photos/azi_px.jpg
            //push: X:\jsc.svn\examples\javascript\synergy\css\CSSAzimuthMapViz\CSSAzimuthMapViz\Textures/azi_nz.jpg -> /sdcard/oculus/360Photos/azi_nz.jpg
            //push: X:\jsc.svn\examples\javascript\synergy\css\CSSAzimuthMapViz\CSSAzimuthMapViz\Textures/azi_ny.jpg -> /sdcard/oculus/360Photos/azi_ny.jpg
            //push: X:\jsc.svn\examples\javascript\synergy\css\CSSAzimuthMapViz\CSSAzimuthMapViz\Textures/azi_nx.jpg -> /sdcard/oculus/360Photos/azi_nx.jpg
            //6 files pushed. 0 files skipped.
            //466 KB/s (969865 bytes in 2.030s)

            //C:\Windows\system32> x:\util\android-sdk-windows\platform-tools\adb.exe shell cp /sdcard/oculus/360Photos/humus.thm /sdcard/oculus/360Photos/azi.thm

            Action <string, string> copy =
                (from, to) =>
            {
                try
                {
                    // http://gis.stackexchange.com/questions/92907/re-project-raster-image-from-mercator-to-equirectangular

                    // https://en.wikipedia.org/wiki/List_of_map_projections
                    // Web Mercator
                    // https://xkcd.com/977/
                    // mercator?
                    var value = this.getResources().getAssets().open(from);
                    var s     = new __NetworkStream {
                        InternalInputStream = value
                    };

                    // 1,392,914
                    //var buffer = new byte[1392914];
                    var buffer = new byte[4392914];

                    var len = s.Read(buffer, 0, buffer.Length);


                    var m = new MemoryStream();

                    m.Write(buffer, 0, len);

                    //s.CopyTo(

                    File.WriteAllBytes(to, m.ToArray());
                }
                catch
                {
                    Console.WriteLine("about to convince NDK what the first image should be... fault");
                }
            };

            // https://sites.google.com/a/jsc-solutions.net/work/knowledge-base/15-dualvr/20150807/ovroculus360photosndk
            copy("2_no_clouds_4k.jpg", "/sdcard/oculus/360Photos/0.jpg");
            //copy("1.jpg", "/sdcard/oculus/360Photos/1.jpg");



            // https://sites.google.com/a/jsc-solutions.net/work/knowledge-base/15-dualvr/20150724/invaders
            //copy("celestial-joshua-trees-milky-way-in-saline-va.jpg", "/sdcard/oculus/360Photos/2.jpg");


            //Implementation not found for type import :
            //type: System.IO.DirectoryInfo
            //method: System.IO.FileInfo[] GetFiles()
            //Did you forget to add the [Script] attribute?
            //Please double check the signature!

            //Path.get

            var emptyFiles =
                from pf in new DirectoryInfo("/sdcard/oculus/360Photos/").GetFiles()
                where pf.Extension.ToLower() == ".jpg"
                where pf.Length == 0
                select pf;

            foreach (var emptyFile in emptyFiles.ToArray())
            {
                Console.WriteLine(new { emptyFile });

                emptyFile.Delete();
            }


            Console.WriteLine("about to convince NDK what the first image should be... done");


            var intent                = getIntent();
            var commandString         = com.oculus.vrappframework.VrActivity.getCommandStringFromIntent(intent);
            var fromPackageNameString = com.oculus.vrappframework.VrActivity.getPackageStringFromIntent(intent);
            var uriString             = com.oculus.vrappframework.VrActivity.getUriStringFromIntent(intent);

            // D/CrashAnrDetector( 3472):     #00 pc 00092ac0  /data/app/OVROculus360Photos.Activities-1/lib/arm/libmain.so (OVR::ovrMessageQueue::PostMessage(char const*, bool, bool)+8)


            // https://sites.google.com/a/jsc-solutions.net/work/knowledge-base/15-dualvr/20160103/oculus360photossdk
            this.appPtr = OVROculus360Photos.Activities.xMarshal.nativeSetAppInterface(
                this,
                fromPackageNameString,
                commandString,
                uriString
                );

            var args = new args
            {
            };

            var uploadLength   = 0L;
            var uploadPosition = 0L;

            var sw = Stopwatch.StartNew();

            #region mDraw
            var mDraw = new DrawOnTop(this)
            {
                // yes it appears top left.

                //text = "GearVR HUD"
                text = () => sw.ElapsedMilliseconds + "ms "
                       //+ "\n " + Path.GetFileName(args.filename)
                       + "\n " + args.filename

                       + "\n " + new
                {
                    upload = (int)(100 * (uploadPosition + 1) / (args.filesize + 1)) + "%",
                    uploadPosition,
                    args.filesize,

                    // can we capture pointer?

                    args.x,
                    args.y,
                    args.z,

                    //uploadLength
                }.ToString().Replace(",", ",\n")

                // X:\jsc.svn\examples\javascript\chrome\apps\WebGL\ChromeEquirectangularPanorama\ChromeEquirectangularPanorama\Application.cs
            };
            #endregion


            //Task.Run(

            #region sendTracking
            Action <IPAddress> sendTracking = nic =>
            {
                var port = new Random().Next(16000, 40000);

                //new IHTMLPre { "about to bind... " + new { port } }.AttachToDocument();

                // where is bind async?
                var socket = new UdpClient(
                    new IPEndPoint(nic, port)
                    );


                // who is on the other end?
                var nmessage = args.x + ":" + args.y + ":" + args.z + ":0:" + args.filename;

                var data = Encoding.UTF8.GetBytes(nmessage);      //creates a variable b of type byte


                //new IHTMLPre { "about to send... " + new { data.Length } }.AttachToDocument();

                // X:\jsc.svn\examples\javascript\chrome\apps\ChromeUDPNotification\ChromeUDPNotification\Application.cs
                //Console.WriteLine("about to Send");
                // X:\jsc.svn\examples\javascript\chrome\apps\WebGL\ChromeEquirectangularPanorama\ChromeEquirectangularPanorama\Application.cs
                socket.Send(
                    data,
                    data.Length,
                    hostname: "239.1.2.3",
                    port: 49834
                    );



                socket.Close();
            };
            #endregion



            //I/System.Console( 9109): 2395:1fb3 enter __UdpClient ctor
            //I/System.Console( 9109): 2395:1fb3 enter __UdpClient before this.Client
            //I/System.Console( 9109): 2395:1fb3 enter __UdpClient after this.Client { Client = ScriptCoreLibJava.BCLImplementation.System.Net.Sockets.__Socket@4f1c02b }
            //I/System.Console( 9109): 2395:1fb3 enter GetAllNetworkInterfaces
            //I/System.Console( 9109): 2395:1fb3 enter __UdpClient ctor

            string current = null;
            byte[] bytes   = null;

            new Thread(
                delegate()
            {
                // bg thread


                // bug out 1sec.
                Thread.Sleep(1000);
                // await gear on

                while (true)
                {
                    // collect tracking from ndk
                    // broadcast to udp


                    //Thread.Sleep(1000 / 15);

                    //var a = new
                    //{
                    //    // for java do we also do the fields?
                    //    x = 0
                    //};

                    args.filename = OVROculus360Photos.Activities.xMarshal.stringFromJNI(args);

                    //E/AndroidRuntime( 7601): Caused by: java.lang.NullPointerException: Attempt to invoke virtual method 'char[] java.lang.String.toCharArray()' on a null object reference
                    //E/AndroidRuntime( 7601):        at java.io.File.fixSlashes(File.java:185)
                    //E/AndroidRuntime( 7601):        at java.io.File.<init>(File.java:134)
                    //E/AndroidRuntime( 7601):        at ScriptCoreLibJava.BCLImplementation.System.IO.__File.Exists(__File.java:57)
                    //E/AndroidRuntime( 7601):        at OVROculus360PhotosHUD.Activities.ApplicationActivity___c__DisplayClass1d._onCreate_b__1b(ApplicationActivity___c__DisplayClass1d.java:95)



                    // uplink 144Mbps
                    // 18 MBps
                    #region udp broadcast
                    // overkill at 60hz
                    NetworkInterface.GetAllNetworkInterfaces().WithEach(
                        n =>
                    {
                        // X:\jsc.svn\examples\java\android\forms\FormsUDPJoinGroup\FormsUDPJoinGroup\ApplicationControl.cs
                        // X:\jsc.svn\core\ScriptCoreLibJava\BCLImplementation\System\Net\NetworkInformation\NetworkInterface.cs

                        var IPProperties    = n.GetIPProperties();
                        var PhysicalAddress = n.GetPhysicalAddress();



                        foreach (var ip in IPProperties.UnicastAddresses)
                        {
                            // ipv4
                            if (ip.Address.AddressFamily == System.Net.Sockets.AddressFamily.InterNetwork)
                            {
                                if (!IPAddress.IsLoopback(ip.Address))
                                {
                                    if (n.SupportsMulticast)
                                    {
                                        //fWASDC(ip.Address);
                                        //fParallax(ip.Address);
                                        //fvertexTransform(ip.Address);
                                        sendTracking(ip.Address);
                                    }
                                }
                            }
                        }
                    }
                        );



                    #endregion

                    if (args.filename != null)
                    {
                        if (File.Exists(args.filename))
                        {
                            if (current != args.filename)
                            {
                                current = args.filename;

                                var ff = new FileInfo(args.filename);

                                args.filesize = ff.Length;

                                // we are not on ui thread.
                                // HUD thread can freeze...
                                // mmap?
                                bytes = File.ReadAllBytes(args.filename);

                                // now broadcast. at 500KBps in segments.
                                // 8MB is 16 segments then.

                                if (bytes.Length > 0)
                                {
                                    NetworkInterface.GetAllNetworkInterfaces().WithEach(
                                        n =>
                                    {
                                        // X:\jsc.svn\examples\java\android\forms\FormsUDPJoinGroup\FormsUDPJoinGroup\ApplicationControl.cs
                                        // X:\jsc.svn\core\ScriptCoreLibJava\BCLImplementation\System\Net\NetworkInformation\NetworkInterface.cs

                                        var IPProperties    = n.GetIPProperties();
                                        var PhysicalAddress = n.GetPhysicalAddress();



                                        foreach (var ip in IPProperties.UnicastAddresses)
                                        {
                                            // ipv4
                                            if (ip.Address.AddressFamily == System.Net.Sockets.AddressFamily.InterNetwork)
                                            {
                                                if (!IPAddress.IsLoopback(ip.Address))
                                                {
                                                    if (n.SupportsMulticast)
                                                    {
                                                        //fWASDC(ip.Address);
                                                        //fParallax(ip.Address);
                                                        //fvertexTransform(ip.Address);
                                                        //sendTracking(ip.Address);

                                                        var port = new Random().Next(16000, 40000);

                                                        //new IHTMLPre { "about to bind... " + new { port } }.AttachToDocument();

                                                        // where is bind async?
                                                        var socket = new UdpClient(
                                                            new IPEndPoint(ip.Address, port)
                                                            );


                                                        //// who is on the other end?
                                                        //var nmessage = args.x + ":" + args.y + ":" + args.z + ":0:" + args.filename;

                                                        //var data = Encoding.UTF8.GetBytes(nmessage);      //creates a variable b of type byte

                                                        // http://stackoverflow.com/questions/25841/maximum-buffer-length-for-sendto

                                                        new { }.With(
                                                            async delegate
                                                        {
                                                            // reached too far?
                                                            if (bytes.Length == 0)
                                                            {
                                                                return;
                                                            }

                                                            var current0 = current;

                                                            var r        = new MemoryStream(bytes);
                                                            uploadLength = r.Length;

                                                            var data = new byte[65507];

                                                            next:

                                                            if (current0 != current)
                                                            {
                                                                return;
                                                            }

                                                            var cc = r.Read(data, 0, data.Length);

                                                            uploadPosition = r.Position;

                                                            if (cc <= 0)
                                                            {
                                                                return;
                                                            }

                                                            //new IHTMLPre { "about to send... " + new { data.Length } }.AttachToDocument();

                                                            // X:\jsc.svn\examples\javascript\chrome\apps\ChromeUDPNotification\ChromeUDPNotification\Application.cs
                                                            //Console.WriteLine("about to Send");
                                                            // X:\jsc.svn\examples\javascript\chrome\apps\WebGL\ChromeEquirectangularPanorama\ChromeEquirectangularPanorama\Application.cs
                                                            await socket.SendAsync(
                                                                data,
                                                                cc,
                                                                hostname: "239.1.2.3",
                                                                port: 49000
                                                                );

                                                            //await Task.Delay(1000 / 15);
                                                            //await Task.Delay(1000 / 30);

                                                            // no corruption
                                                            await Task.Delay(1000 / 20);

                                                            goto next;
                                                        }
                                                            );

                                                        //socket.Close();
                                                    }
                                                }
                                            }
                                        }
                                    }
                                        );
                                }
                            }
                        }
                    }

                    if (uploadPosition < args.filesize)
                    {
                        mDraw.color = android.graphics.Color.YELLOW;
                    }
                    else
                    {
                        mDraw.color = android.graphics.Color.GREEN;
                    }

                    mDraw.postInvalidate();
                    Thread.Sleep(1000 / 30);
                    //Thread.Sleep(1000 / 2);
                    //Thread.Sleep(1000 / 15);
                }
            }
                ).Start();

            //this.ondispatchTouchEvent += @event =>
            //{

            //    int action = @event.getAction();
            //    float x = @event.getRawX();
            //    float y = @event.getRawY();
            //    //if (action == MotionEvent.ACTION_UP)
            //    {
            //        var halfx = 2560 / 2;
            //        var halfy = 1440 / 2;

            //        mDraw.x = (int)(500 + halfx - x);
            //        mDraw.y = (int)(600 + y - halfy);
            //        mDraw.text = () => sw.ElapsedMilliseconds + "ms \n" + new { x, y, action }.ToString();
            //        //Console.WriteLine(" ::dispatchTouchEvent( " + action + ", " + x + ", " + y + " )");
            //    }

            //    // can we move hud around and record it to gif or mp4?

            //    return true;
            //};

            // X:\jsc.svn\examples\java\android\synergy\OVRVrCubeWorldSurfaceView\OVRVrCubeWorldSurfaceView\ApplicationActivity.cs
            // X:\jsc.svn\examples\java\android\AndroidLacasCameraServerActivity\AndroidLacasCameraServerActivity\ApplicationActivity.cs
            addContentView(mDraw, new ViewGroup.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT));


            // "x:\util\android-sdk-windows\platform-tools\adb.exe" connect 192.168.1.126:5555
            // cmd /K x:\util\android-sdk-windows\platform-tools\adb.exe logcat -s "JniUtils"  "System.Console" "art"


            // E/JniUtils(14136): couldn't get isHybridApp, (Landroid/app/Activity;)Z

            //            I/Oculus360Photos( 9199): nativeSetAppInterface
            //I/App     ( 9199): VrAppInterface::SetActivity:
            //I/App     ( 9199): new AppLocal( 0xf51512b0 0xff8b6b80 0xeef69900 )
            //I/App     ( 9199): ----------------- AppLocal::AppLocal() -----------------
            //E/JniUtils( 9199): couldn't get getInternalCacheMemoryInBytes, (Landroid/app/Activity;)J

            //            I/JniUtils(26390): Using caller's JNIEnv
            //E/JniUtils(26390): couldn't get getInstalledPackagePath, (Ljava/lang/String;)Ljava/lang/String;

            //            I/System.Console( 3652): 0e44:0001 Searching installed packages for 'com.oculus.systemactivities'
            //I/JniUtils( 3652): ovr_GetCurrentPackageName() = OVROculus360PhotosHUD.Activities
            //I/JniUtils( 3652): ovr_GetPackageCodePath() = '/data/app/OVROculus360PhotosHUD.Activities-1/base.apk'
            //W/art     ( 3652): Attempt to remove local handle scope entry from IRT, ignoring
            //W/art     ( 3652): Attempt to remove local handle scope entry from IRT, ignoring
            //W/art     ( 3652): Attempt to remove local handle scope entry from IRT, ignoring
            //I/JniUtils( 3652): ovr_GetCurrentActivityName() = OVROculus360PhotosHUD.Activities.ApplicationActivity
            //I/JniUtils( 3652): ovr_GetCurrentPackageName() = OVROculus360PhotosHUD.Activities
            //E/JniUtils( 3652): couldn't get getLocalizedString, (Ljava/lang/String;)Ljava/lang/String;
            //I/JniUtils( 4380): ovr_GetCurrentActivityName() = com.oculus.home.HomeActivity

            // ffs
        }
예제 #37
0
        private void ProcessData(byte[] data, args a)
        {
            string        msg = Encoding.UTF8.GetString(data);
            PBCommandType cmd;
            string        strTmp = PBClimber.getParam(msg, CommandStart);

            try { cmd = (PBCommandType)Enum.Parse(typeof(PBCommandType), strTmp); }
            catch
            {
                sendError(a);
                return;
            }
            PBHosterEventArgs e = null;
            ManualResetEvent  ev = new ManualResetEvent(false);
            int route, iid;

            switch (cmd)
            {
            case PBCommandType.GETLIST:
                e = new PBHosterEventArgs(cmd, null, 0, ev);
                break;

            case PBCommandType.GETNEXT:
                if (int.TryParse(PBClimber.getParam(msg, "ROUTE"), out route))
                {
                    e = new PBHosterEventArgs(cmd, null, route, ev);
                }
                break;

            case PBCommandType.GETBYIID:
                if (int.TryParse(PBClimber.getParam(msg, "ROUTE"), out route))
                {
                    if (int.TryParse(PBClimber.getParam(msg, "IID"), out iid))
                    {
                        e = new PBHosterEventArgs(cmd,
                                                  new PBClimber(iid, "", "", 0), route, ev);
                    }
                }
                break;

            case PBCommandType.GETBYSTART:
                if (int.TryParse(PBClimber.getParam(msg, "ROUTE"), out route))
                {
                    if (int.TryParse(PBClimber.getParam(msg, "START"), out iid))
                    {
                        e = new PBHosterEventArgs(cmd,
                                                  new PBClimber(0, "", "", iid), route, ev);
                    }
                }
                break;

            case PBCommandType.SETRES:
                if (int.TryParse(PBClimber.getParam(msg, "ROUTE"), out route))
                {
                    PBClimber clm = PBClimber.GetFromString(msg);
                    if (clm != null && !clm.Empty)
                    {
                        e = new PBHosterEventArgs(cmd, clm, route, ev);
                    }
                }
                break;
            }
            bool toSetErr = true;

            if (e != null)
            {
                if (PBHosterEvent != null)
                {
                    PBHosterEvent(this, e);
                    toSetErr = false;
                    ev.WaitOne();
                }
            }
            if (toSetErr)
            {
                sendError(a);
            }
            else
            {
                string pck = CommandStart + "=";
                switch (cmd)
                {
                case PBCommandType.GETLIST:
                    pck += PBCommandType.LIST.ToString() + ";NAME=" + opResStr + ";";
                    break;

                case PBCommandType.SETRES:
                    if (opRes)
                    {
                        pck += PBCommandType.ACK.ToString() + ";";
                    }
                    else
                    {
                        pck += PBCommandType.DECL.ToString() + ";";
                    }
                    break;

                default:
                    pck += clm.ToString();
                    break;
                }
                pck += CommandEnd;
                List <byte> pc = new List <byte>();
                pc.Add(CommandPr);
                foreach (byte b in Encoding.UTF8.GetBytes(pck))
                {
                    pc.Add(b);
                }
                pc.Add(CommandTail);
                a.buffer = pc.ToArray();
                a.cnt    = 0;
                a.s.BeginSend(a.buffer, 0, a.buffer.Length, SocketFlags.None,
                              EndSend, a);
            }
        }
예제 #38
0
    public static StringBuilder Build_DelegateFunction(Type classType, MemberInfo memberInfo, Type delType,
                                                       int methodTag, int argIndex)
    {
        // building a closure
        // a function having a up-value: jsFunction

        string getDelFunctionName = GetMethodArg_DelegateFuncionName(classType, memberInfo.Name, methodTag, argIndex);

        var sb         = new StringBuilder();
        var delInvoke  = delType.GetMethod("Invoke");
        var ps         = delInvoke.GetParameters();
        var returnType = delType.GetMethod("Invoke").ReturnType;

        var argsParam = new args();

        for (int i = 0; i < ps.Length; i++)
        {
            argsParam.Add(ps[i].Name);
        }

        // format as <t,u,v>
        string stringTOfMethod = string.Empty;

        if (delType.ContainsGenericParameters)
        {
            var arg = new args();
//            var hashSetNames = new HashSet<string>();
            foreach (var t in delType.GetGenericArguments())
            {
                // 泛型参数,重复类型的一个即可了,可能处理这里还不够
//                if (hashSetNames.Add(t.Name))
                {
                    arg.Add(t.Name);
                }
            }
            stringTOfMethod = arg.Format(args.ArgsFormat.GenericT);
        }

        // this function name is used in BuildFields, don't change
        sb.AppendFormat("public static {0} {1}{2}(CSRepresentedObject objFunction)\n[[\n",
                        JSNameMgr.GetTypeFullName(delType, true), // [0]
                        getDelFunctionName,                       // [2]
                        stringTOfMethod                           // [1]
                        );
        sb.Append("    if (objFunction == null || objFunction.jsObjID == 0)\n");
        sb.Append("    [[\n        return null;\n    ]]\n");

        sb.AppendFormat("    var action = JSMgr.getJSFunCSDelegateRel<{0}>(objFunction.jsObjID);\n",
                        JSNameMgr.GetTypeFullName(delType, true));
        sb.Append("    if (action == null)\n    [[\n");
        sb.AppendFormat("        action = ({1}) => \n", JSNameMgr.GetTypeFullName(delType, true),
                        argsParam.Format(args.ArgsFormat.OnlyList));
        sb.AppendFormat("        [[\n");
        sb.AppendFormat("            JSMgr.vCall.CallJSFunctionValue(0, objFunction.jsObjID{0}{1});\n",
                        argsParam.Count > 0 ? ", " : "", argsParam);

        if (returnType != typeof(void))
        {
            sb.Append("            return (" + JSNameMgr.GetTypeFullName(returnType) + ")" + Get_GetJSReturn(returnType) +
                      ";\n");
        }

        sb.AppendFormat("        ]];\n");
        sb.Append("        JSMgr.addJSFunCSDelegateRel(objFunction.jsObjID, action);\n");
        sb.Append("    ]]\n");
        sb.Append("    return action;\n");
        sb.AppendFormat("]]\n");

        return(sb);
    }
 void connection_ServerAuthRequired(object sender, args.ServerEventArgs e)
 {
     Server server = e.Server;
     InserisciPasswordDialogBox ipDialogBox = new InserisciPasswordDialogBox(server.Name);
     ipDialogBox.Owner = this;
     ipDialogBox.ShowDialog();
     if (ipDialogBox.DialogResult.HasValue && (bool)ipDialogBox.DialogResult)
     {
         //Password inserita
         string password = ipDialogBox.Password;
         server.Password = password;
         connection.Connect(ref server);
     }
 }
예제 #40
0
 .AddIf(
     args is not null,
 void connection_ServerError(object sender, args.ServerErrorEventsArgs e)
 {
     switch (e.ErrorCode)
     {
         case ServerErrorEventsArgs.SERVER_ERROR:
             ErrorMessage("Problema con la rete del Server " + e.Server.Name);
             serverAggiunti.Remove(e.Server);
             serverTrovati.Remove(e.Server);
             break;
         case ServerErrorEventsArgs.NETWORK_ERROR:
             ErrorMessage("Connessione assente!");
             serverAggiunti.Clear();
             serverTrovati.Clear();
             break;
         case ServerErrorEventsArgs.KEEP_ALIVE_NOT_RECEIVED:
             ErrorMessage("Problemi di connessione col Server " + e.Server.Name);
             serverAggiunti.Remove(e.Server);
             serverTrovati.Remove(e.Server);
             break;
         case ServerErrorEventsArgs.LOGIN_ERROR:
             ErrorMessage("Errore nella fase di LOGIN col server:\n " + e.Server.Name);
             break;
         case ServerErrorEventsArgs.PASSWORD_ERROR:
             ErrorMessage("Password errata!");
             break;
         default:
             ErrorMessage("Si è verificato un errore inatteso");
             break;
     }
 }