Esempio n. 1
0
        //if access denied execute: "netsh http delete urlacl url=http://+:8001/" (delete for 'localhost', add for public address)
        //open Index.html to run the client
        static void Main(string[] args)
        {
            Directory.SetCurrentDirectory(Path.GetDirectoryName(System.Reflection.Assembly.GetEntryAssembly().Location));

            Connection.MaxMessageSize = 1 * 1024 * 1024; //1MiB
            RPC.AddConverter(new JpgBase64Converter());

            //generate js code
            File.WriteAllText($"../../Site/{nameof(ImageProcessingAPI)}.js", RPCJs.GenerateCallerWithDoc <ImageProcessingAPI>());

            //start server and bind its local and remote API
            var cts = new CancellationTokenSource();
            var t   = Server.ListenAsync("http://localhost:8001/", cts.Token, (c, ws) => c.Bind(new ImageProcessingAPI()));

            Console.Write("{0} ", nameof(Serialization));
            Process.Start(new ProcessStartInfo(Path.GetFullPath("../../Site/Index.html"))
            {
                UseShellExecute = true
            });
            AppExit.WaitFor(cts, t);
        }