Esempio n. 1
0
        static void Main(string[] args)
        {
            var path = ConfigurationManager.AppSettings["path"];

            string[] paths = null;
            if (string.IsNullOrWhiteSpace(path))
            {
                paths = new string[] { GetHome() };
            }
            else
            {
                paths = (path ?? "").Split(';');
            }

            Action a = new Action(() => { Catalogue.Index(paths); });

            a.BeginInvoke(null, null);


            var nancyHost = new Nancy.Hosting.Self.NancyHost(new Uri("http://localhost:1337"));

            Console.WriteLine("Web server started on port {0}", port);
            nancyHost.Start();
            Console.ReadLine();
        }
Esempio n. 2
0
        static void Main(string[] args)
        {
            var host = new Nancy.Hosting.Self.NancyHost(new Uri("http://localhost:8080"));
            host.Start();

            Console.ReadKey();
        }
Esempio n. 3
0
        static void Main(string[] args)
        {
            var nancyHost = new Nancy.Hosting.Self.NancyHost(new Uri("http://localhost:1234"));
            nancyHost.Start();

            Console.ReadLine();
            nancyHost.Stop();
        }
Esempio n. 4
0
        public static void Main(string[] args)
        {
            Console.WriteLine("Hello Nancy 1.4!");
            var nancyhost = new Nancy.Hosting.Self.NancyHost(new Uri("http://localhost:3333"));

            nancyhost.Start();
            Console.ReadLine();
        }
Esempio n. 5
0
        static void Main(string[] args)
        {
            var nancyHost = new Nancy.Hosting.Self.NancyHost(new Uri("http://localhost:8081"), new TodoMvcBootstrap());
            nancyHost.Start();

            Console.ReadLine();
            nancyHost.Stop();
        }
Esempio n. 6
0
 static void Main(string[] args)
 {
     Console.Write("Starting server...");
     var server = new Nancy.Hosting.Self.NancyHost(new Uri("http://localhost:8282"));
     server.Start();
     StaticConfiguration.DisableErrorTraces = false;
     Console.Read();
 }
Esempio n. 7
0
        static void Main(string[] args)
        {
            Console.Write("Starting server...");
            var server = new Nancy.Hosting.Self.NancyHost(new Uri("http://localhost:8282"));

            server.Start();
            StaticConfiguration.DisableErrorTraces = false;
            Console.Read();
        }
Esempio n. 8
0
 public void StopWebService()
 {
     if (host != null)
     {
         host.Dispose();
         host = null;
         log.Info("Order-Rest-Service stopped");
     }
 }
        static void Main(string[] args)
        {
            var nancyHost = new Nancy.Hosting.Self.NancyHost(new Uri("http://localhost:1234"));

            nancyHost.Start();
            Console.WriteLine("NancyFX API running");
            Console.ReadLine();
            nancyHost.Stop();
        }
Esempio n. 10
0
 static void Main(string[] args)
 {
     var host = new Nancy.Hosting.Self.NancyHost(new Uri("http://localhost:8888/Nancy/"));
     host.Start();
     Process.Start("http://localhost:8888/Nancy/");
     Console.WriteLine("Press [ENTER] to stop");
     Console.ReadLine();
     host.Stop();
 }
Esempio n. 11
0
        static void Main(string[] args)
        {
            var nancyHost = new Nancy.Hosting.Self.NancyHost(new Uri("http://localhost:1234"));
            nancyHost.Start();

            Console.WriteLine("Serving... - until being killed");
            Console.ReadLine();

            nancyHost.Stop();
        }
Esempio n. 12
0
        static void Main(string[] args)
        {
            var hostUrl = "http://localhost:" + ConfigurationManager.AppSettings["Port"];
            var nancyHost = new Nancy.Hosting.Self.NancyHost(new Uri(hostUrl));
            nancyHost.Start();

            Console.WriteLine("Nancy host listening on " + hostUrl);

            Console.ReadLine();
            nancyHost.Stop();
        }
Esempio n. 13
0
 static void Main()
 {
     using (var host = new Nancy.Hosting.Self.NancyHost(new Uri("http://localhost:1234")))
     {
         host.Start();
         Console.WriteLine("Running on http://localhost:1234");
         new LasModules();
         Console.ReadLine();
         host.Stop();
     }
 }
Esempio n. 14
0
        static void Main(string[] args)
        {
            var nancyHost = new Nancy.Hosting.Self.NancyHost(new Uri("http://localhost:9664"));
             nancyHost.Start();
             Console.WriteLine("Web server running...");

            Process.Start("http://localhost:9664");

             Console.ReadLine();
             nancyHost.Stop();
        }
Esempio n. 15
0
 public static void Main(string[] args)
 {
     var config = new Nancy.Hosting.Self.HostConfiguration();
     config.UnhandledExceptionCallback += (ex) => {
         Console.WriteLine(ex);
     };
     var nancyHost = new Nancy.Hosting.Self.NancyHost(config, new Uri("http://localhost:7000"));
     nancyHost.Start();
     Console.ReadLine();
     nancyHost.Stop();
     System.Threading.Thread.Sleep(1000);
 }
Esempio n. 16
0
        static void Main(string[] args)
        {
            __exit = new AutoResetEvent(false);

            var nancyHost = new Nancy.Hosting.Self.NancyHost(new Uri("http://localhost:1234"));
            nancyHost.Start();

            Console.WriteLine("Serving...");
            __exit.WaitOne();

            nancyHost.Stop();
        }
Esempio n. 17
0
        public void Start()
        {
            const string url       = "http://localhost:9090";
            var          nancyHost = new Nancy.Hosting.Self.NancyHost(new Uri(url));

            nancyHost.Start();
            CheckMailThread = new Thread(CheckMailCaller);
            CheckMailThread.Start();


            Console.WriteLine("Billing service is listening on {0}", url);
        }
Esempio n. 18
0
        static void Main(string[] args)
        {
            var hostUrl   = "http://localhost:" + ConfigurationManager.AppSettings["Port"];
            var nancyHost = new Nancy.Hosting.Self.NancyHost(new Uri(hostUrl));

            nancyHost.Start();

            Console.WriteLine("Nancy host listening on " + hostUrl);

            Console.ReadLine();
            nancyHost.Stop();
        }
        static void Main(string[] args)
        {
            var port      = 8765;
            var nancyHost = new Nancy.Hosting.Self.NancyHost(new Uri("http://localhost:" + port));

            Console.WriteLine("Running port: {0}", port);

            nancyHost.Start();

            Console.ReadKey();

            nancyHost.Stop();
        }
Esempio n. 20
0
        public static void Main(string[] args)
        {
            var homeUri = new Uri("http://localhost:8080");

            using (var host = new Nancy.Hosting.Self.NancyHost(homeUri))
            {
                host.Start();

                Console.WriteLine($"Interaction Host listening on {homeUri}");
                Console.WriteLine("Press ENTER to stop...");
                Console.ReadLine();
            }
        }
Esempio n. 21
0
        public static void StartHost(UpdateRegionDelegate update, GetMapRulesDelegate rules, CheckAPIKeyDelegate keychecker, string domain = "localhost", uint port = 6473, bool useSSL = true)
        {
            _updateRegionDelegate = update;
            _getMapRulesDelegate  = rules;
            _checkAPIKeyDelegate  = keychecker;

            var protocol = useSSL ? "https" : "http";

            BINDING_CONFIG.BodyOnly = true;

            _host = new Nancy.Hosting.Self.NancyHost(new Uri($"{protocol}://{domain}:{port}"));
            _host.Start();
        }
Esempio n. 22
0
        static void Main(string[] args)
        {
            string httpUrl      = "http://0.0.0.0:9664";
            string websocketUrl = "ws://0.0.0.0:9966";

            if (OperatingSystem.IsWindows())
            {
                httpUrl      = "http://127.0.0.1:9664";
                websocketUrl = "ws://127.0.0.1:9966";
            }
            var tokenSource      = new CancellationTokenSource();
            CancellationToken ct = tokenSource.Token;

            if (args.Length > 0)
            {
                r2warsStatic.torneo.SetWarriorsDirectory(args[0]);
            }

            var taskA = new Task(() =>
            {
                var nancyHost = new Nancy.Hosting.Self.NancyHost(new Uri(httpUrl), new CustomBootstrapper());
                nancyHost.Start();
                Console.WriteLine("Web server running at " + httpUrl);

                Process.Start(httpUrl);


                while (!ct.IsCancellationRequested)
                {
                    Thread.Sleep(1000);
                }
                nancyHost.Stop();
            }, tokenSource.Token);

            var taskB = new Task(() =>
            {
                var wssv = new WebSocketServer(websocketUrl);
                wssv.AddWebSocketService <r2warsWebSocket>("/r2wars");
                wssv.Start();
                while (!ct.IsCancellationRequested)
                {
                    Thread.Sleep(1000);
                }
                wssv.Stop();
            }, tokenSource.Token);

            taskA.Start();
            taskB.Start();
            Console.ReadKey();
            tokenSource.Cancel();
        }
Esempio n. 23
0
        public void RunWebService()
        {
            int port = 50006;

            int.TryParse(BauerLib.Registry.ServicePort, out port);

            if (PortInUse(port))
            {
                log.ErrorFormat("Error {0} in use !", port);
                return;
            }

            string baseAddress = string.Format("http://localhost:{0}", port);

            Nancy.ViewEngines.DotLiquid.DotLiquidRegistrations r = new Nancy.ViewEngines.DotLiquid.DotLiquidRegistrations();
            DotLiquid.Template.NamingConvention = new DotLiquid.NamingConventions.CSharpNamingConvention();

            Nancy.Hosting.Self.HostConfiguration hostConfigs = new Nancy.Hosting.Self.HostConfiguration();
            // netsh http add urlacl url=http://+:50006/ user=EVERYONE
            // netsh http add urlacl url=http://+:50006/ user=JEDER
            hostConfigs.UrlReservations.CreateAutomatically = false;
            hostConfigs.RewriteLocalhost = true;

            int retries = 6;

            while (retries > 0)
            {
                try
                {
                    host = new Nancy.Hosting.Self.NancyHost(hostConfigs, new Uri(baseAddress));
                    host.Start();
                    retries = -1;
                }
                catch (Exception ex)
                {
                    log.Error("Error starting rest-service", ex);
                    retries--;
                    if (retries <= 3)
                    {
                        hostConfigs.UrlReservations.CreateAutomatically = true;
                    }
                    System.Threading.Thread.Sleep(500);
                }
            }
            log.InfoFormat("Running on {0}", baseAddress);

            if (Environment.UserInteractive)
            {
                System.Diagnostics.Process.Start(baseAddress);
            }
        }
        public TimesheetApp()
        {
            InitializeComponent();

            const string appAddress = "http://*****:*****@"Timesheet Standalone. Navigate to: " + appAddress;
            this.Load += (sender, args) => this.addressTextbox.Invoke(textUpdate); ;
            this.FormClosed += (sender, args) => nancyHost.Stop();
        }
        public TimesheetApp()
        {
            InitializeComponent();

            const string appAddress = "http://*****:*****@"Timesheet Standalone. Navigate to: " + appAddress;

            this.Load       += (sender, args) => this.addressTextbox.Invoke(textUpdate);;
            this.FormClosed += (sender, args) => nancyHost.Stop();
        }
Esempio n. 26
0
 public string GetAuthorizationCode()
 {
     using (var host = new Nancy.Hosting.Self.NancyHost(new Nancy.Hosting.Self.HostConfiguration()
     {
         UrlReservations = { CreateAutomatically = true }
     }, new System.Uri(redirectUrl)))
     {
         host.Start();
         eventWaitHandler = new System.Threading.EventWaitHandle(false, System.Threading.EventResetMode.ManualReset);
         Log("launch operating system default web browser: " + url);
         System.Diagnostics.Process.Start(new System.Diagnostics.ProcessStartInfo(url));
         eventWaitHandler.WaitOne();
         Log("authorization code: " + authorizationCode);
         System.Threading.Thread.Sleep(1000);
     }
     return(authorizationCode);
 }
Esempio n. 27
0
        public void RunTests(IEnumerable <TestCase> tests, IRunContext runContext, IFrameworkHandle frameworkHandle)
        {
            var configuration = new Mocha.BddConfiguration(); //TODO: unhardcode
            var harnessFile   = "harness.html";

            var sources = tests
                          .Select(t => t.Source)
                          .Distinct();

            //TODO: allow multiple roots / multiple configs / multiple projects
            var rootPath = PathFinder.FindRootDirectoryForFile(sources.First());

            HarnessBuilder.CreateHarnessFile(configuration, sources, rootPath, harnessFile);

            var hostConfig = new Nancy.Hosting.Self.HostConfiguration()
            {
                RewriteLocalhost = true,
                UrlReservations  = new Nancy.Hosting.Self.UrlReservations()
                {
                    CreateAutomatically = true
                }
            };
            var port = "8081"; //TODO: unhardcode
            var uri  = String.Format("http://localhost:{0}", port);

            var host = new Nancy.Hosting.Self.NancyHost(
                new Uri(uri),
                new NancySettingsBootstrapper(rootPath),
                hostConfig
                );

            host.Start();

            //Run phantom per harness
            var harnessUri    = uri + "/" + harnessFile;
            var phantomrunner = new PhantomRunner(frameworkHandle, tests);
            var phantomResult = phantomrunner.Run(harnessUri);

            phantomResult.Wait();

            host.Stop();
        }
Esempio n. 28
0
        static void Main(string[] args)
        {
            var path = ConfigurationManager.AppSettings["path"];
            string[] paths = null;
            if (string.IsNullOrWhiteSpace(path))
            {
                paths = new string[] { GetHome() };
            }
            else
            {
                paths = (path ?? "").Split(';');
            }

            Action a = new Action(() => { Catalogue.Index(paths); });
            a.BeginInvoke(null, null);

            var nancyHost = new Nancy.Hosting.Self.NancyHost(new Uri("http://localhost:1337"));
            Console.WriteLine("Web server started on port {0}", port);
            nancyHost.Start();
            Console.ReadLine();
        }
Esempio n. 29
0
        static void Main(string[] args)
        {
            Console.WriteLine("--Welcome to OpenBank--");
            Console.WriteLine();
            Console.Write("Starting up...");

            System.Net.ServicePointManager.ServerCertificateValidationCallback = CertificateValidator;

            string port = ConfigurationManager.AppSettings["port"];

            using (var nancyHost = new Nancy.Hosting.Self.NancyHost(new Uri(string.Concat("http://localhost:", port))))
            {
                nancyHost.Start();
                Console.WriteLine("success!");

                Console.WriteLine(string.Format("Server listening on port {0} and waiting for connections.", port));
                Console.WriteLine(string.Format("Navigate to http://localhost:{0}/ for help.", port));

                Wait();

                nancyHost.Stop();
            }
        }
Esempio n. 30
0
        static void Main(string[] args)
        {
            Uri domainUri = null;

            try
            {
                domainUri = new Uri("http://localhost:8088");
            }
            catch (Exception e)
            {
                Console.WriteLine(e.Message);
                Environment.Exit(0);
            }

            // create a new self-host server
            var nancyHost = new Nancy.Hosting.Self.NancyHost(domainUri);

            // start
            nancyHost.Start();
            Console.WriteLine("REST service listening on " + DOMAIN);
            // stop with an <Enter> key press
            Console.ReadLine();
            nancyHost.Stop();
        }
Esempio n. 31
0
        private void EnableRemoteControl()
        {
            Task.Factory.StartNew((System.Action)(() =>
            {
                remoteControl = ApiServer.InitNancy(apiServer =>
                {
                    remoteLogger.Info("got unity init, device_id=" + ApiServer.device_id + " movies=[\n" + string.Join(",\n", ApiServer.movies) + "]");
                    remoteLogger.Info("init complete");
                }
                                                    );

                #region GearVR slave app

                ApiServer.OnBackPressed += () =>
                {
                    remoteLogger.Info("back pressed");
                };

                ApiServer.OnStateChange += (state) =>
                {
                    remoteLogger.Info("state changed: " + state);

                    switch (state)
                    {
                    //case ApiServer.State.off:
                    //	Execute.OnUIThreadAsync(() =>
                    //	{
                    //		if(IsPlaying)
                    //			Stop();
                    //	});
                    //	break;

                    case ApiServer.State.pause:
                        Execute.OnUIThreadAsync(() =>
                        {
                            if (IsPlaying && !IsPaused)
                            {
                                Pause();
                                _mediaDecoder.Seek(remoteTime);
                            }
                        });
                        break;

                    case ApiServer.State.play:
                        Execute.OnUIThreadAsync((System.Action)(() =>
                        {
                            if (!_ready)
                            {
                                this.OpenURI((string)SelectedFileName);
                            }
                            else
                            {
                                PlayPause();
                            }
                        }));
                        break;

                    case ApiServer.State.stop:
                        Execute.OnUIThreadAsync(() =>
                        {
                            if (IsPlaying)
                            {
                                Stop();
                            }
                        });
                        break;
                    }
                };

                ApiServer.OnConfirmPlay += (path) =>
                {
                    remoteLogger.Info("path = " + path);
                    string remoteFile = path.Split('/').Last();
                    if (File.Exists(Logic.Instance.settings.RemoteControlMovieDirectory + Path.DirectorySeparatorChar + remoteFile))
                    {
                        IsFileSelected   = true;
                        SelectedFileName = Logic.Instance.settings.RemoteControlMovieDirectory + Path.DirectorySeparatorChar + remoteFile;
                    }
                    else
                    {
                        IsFileSelected   = false;
                        SelectedFileName = "";

                        Execute.OnUIThreadAsync(() => NotificationCenter.PushNotification(new NotificationViewModel("Requested file \"" + remoteFile + "\" not found in video library.",
                                                                                                                    () =>
                        {
                            System.Diagnostics.Process.Start(Logic.Instance.settings.RemoteControlMovieDirectory);
                        }, "open folder")));
                    }
                };

                ApiServer.OnPos += (euler, t) =>
                {
                    //Log("[remote] position = " + euler.Item1 + ", " + euler.Item2 + ", " + euler.Item3, ConsoleColor.DarkGreen);
                    //remoteTime = (float)(t * MaxTime);
                    //if (DXCanvas.Scene != null)
                    //{
                    //	((Scene)DXCanvas.Scene).SetLook(euler);
                    //}
                };

                ApiServer.OnPosQuaternion += (quat, t) =>
                {
                    //Log("[remote] position = " + quat.Item1 + ", " + euler.Item2 + ", " + euler.Item3, ConsoleColor.DarkGreen);
                    remoteTime = (float)(t * MaxTime);
                    if (DXCanvas.Scene != null)
                    {
                        ((Scene)DXCanvas.Scene).SetLook(quat);
                    }
                };



                ApiServer.OnInfo += (msg) =>
                {
                    remoteLogger.Info("[remote] msg = " + msg);
                };

                #endregion


                #region Remote controll app - control API

                ApiServer.CommandLoadHandler = (movie, autoplay) =>
                {
                    remoteLogger.Info("[remote] path = " + movie);
                    string remoteFile = movie.Contains('/') ? movie.Split('/').Last() : movie;
                    if (File.Exists(Logic.Instance.settings.RemoteControlMovieDirectory + Path.DirectorySeparatorChar + remoteFile))
                    {
                        IsFileSelected   = true;
                        SelectedFileName = Logic.Instance.settings.RemoteControlMovieDirectory + Path.DirectorySeparatorChar + remoteFile;

                        this.LoadMedia(autoplay);

                        return(true);
                    }
                    else
                    {
                        IsFileSelected   = false;
                        SelectedFileName = "";

                        Execute.OnUIThreadAsync(() => NotificationCenter.PushNotification(new NotificationViewModel("Requested file \"" + remoteFile + "\" not found in video library.",
                                                                                                                    () =>
                        {
                            System.Diagnostics.Process.Start(Logic.Instance.settings.RemoteControlMovieDirectory);
                        }, "open folder")));
                        return(false);
                    }
                };

                ApiServer.CommandMoviesHandler = () =>
                {
                    List <string> movies = new List <string>();
                    var dir = Logic.Instance.settings.RemoteControlMovieDirectory;
                    if (Directory.Exists(dir))
                    {
                        try
                        {
                            var files = Directory.GetFiles(dir);
                            foreach (string file in files)
                            {
                                if (MediaDecoder.CheckExtension(Path.GetExtension(file)))
                                {
                                    movies.Add(Path.GetFileName(file));
                                }
                            }
                        }
                        catch (Exception exc)
                        {
                        }
                    }
                    return(movies.ToArray());
                };

                ApiServer.CommandPauseHandler = () =>
                {
                    if (IsPlaying && !IsPaused)
                    {
                        Pause();
                        return(true);
                    }
                    return(false);
                };

                ApiServer.CommandPlayingHandler = () =>
                {
                    var info = new ApiServer.PlayingInfo()
                    {
                        is_playing = false,
                        movie      = "",
                        quat_x     = 0f,
                        quat_y     = 0f,
                        quat_z     = 0f,
                        quat_w     = 0f,
                        t          = 0,
                        tmax       = 0
                    };

                    if (IsFileSelected)
                    {
                        info.movie = SelectedFileName;
                    }
                    if (IsPlaying)
                    {
                        info.is_playing = !IsPaused;
                        if (this.DXCanvas.Scene != null)
                        {
                            var q       = ((Scene)this.DXCanvas.Scene).GetCurrentLook();
                            info.quat_x = q.X;
                            info.quat_y = q.Y;
                            info.quat_z = q.Z;
                            info.quat_w = q.W;
                        }
                        info.t    = (float)TimeValue;
                        info.tmax = (float)MaxTime;
                    }

                    return(info);
                };

                ApiServer.CommandSeekHandler = (time) =>
                {
                    if (IsPlaying)
                    {
                        TimeValue = time;
                        return(true);
                    }
                    return(false);
                };

                ApiServer.CommandStopAndResetHandler = () =>
                {
                    if (IsPlaying)
                    {
                        Stop();
                        return(true);
                    }
                    return(false);
                };

                ApiServer.CommandUnpauseHandler = () =>
                {
                    if (IsPlaying && IsPaused)
                    {
                        UnPause();
                        return(true);
                    }
                    if (!IsPlaying && IsFileSelected)
                    {
                        PlayPause();
                        return(true);
                    }
                    return(false);
                };


                #endregion

                IsRemoteControlEnabled = true;
            }));
        }