Esempio n. 1
0
        public Ventriloquist()
        {
            // Load the dynamic library for aggregating audio output devices
            var libPath = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "xamspeech.dylib");

            Dlfcn.dlopen(libPath, 0);

            // Esure paths exist
            if (!Directory.Exists(audiopath))
            {
                Directory.CreateDirectory(audiopath);
            }
            //Console.WriteLine (appsupportpath);
            //if(!Directory.Exists(appsupportpath)) {
            //	Directory.CreateDirectory (appsupportpath);
            //}
            config = Config.GetInstance();
            config.PropertyChanged += async(object sender, System.ComponentModel.PropertyChangedEventArgs e) => {
                if (e.PropertyName.Equals("localonly"))
                {
                    server.Stop();
                    foreach (var socket in allSockets)
                    {
                        try {
                            socket.Close();
                        } catch (Exception ex) {
                        }
                    }
                    websocketserver.ListenerSocket.Close();
                    websocketserver.Dispose();
                    InitHTTPServer();
                }
            };
        }
Esempio n. 2
0
        static void Main(string[] args)
        {
            if (args.Length < 2)
            {
                Console.WriteLine("SendMessage: No username and password specified!");
                return;
            }

            // exit gracefully if possible
            Console.CancelKeyPress += delegate(object sender, ConsoleCancelEventArgs e) {
                e.Cancel  = true;
                isRunning = false;
            };

            var url  = "http://localhost:3131";
            var host = new NancyHost(new Uri(url));

            host.Start();
            Console.WriteLine("Server now running on: " + url);

            // save our logon details
            user = args[0];
            pass = args[1];

            manager = new CallbackManager(Steam3.SteamClient);

            new Callback <SteamClient.ConnectedCallback>(OnConnected, manager);
            new Callback <SteamClient.DisconnectedCallback>(OnDisconnected, manager);

            new Callback <SteamUser.LoggedOnCallback>(OnLoggedOn, manager);
            new Callback <SteamUser.LoggedOffCallback>(OnLoggedOff, manager);

            // we use the following callbacks for friends related activities
            new Callback <SteamUser.AccountInfoCallback>(OnAccountInfo, manager);
            new Callback <SteamFriends.FriendsListCallback>(OnFriendsList, manager);
            new Callback <SteamFriends.PersonaStateCallback>(OnPersonaState, manager);
            new Callback <SteamFriends.FriendAddedCallback>(OnFriendAdded, manager);
            new Callback <SteamFriends.FriendMsgCallback>(OnMsgReceived, manager);

            isRunning = true;

            Console.WriteLine("Connecting to Steam...");

            // initiate the connection
            Steam3.SteamClient.Connect(false);

            // create our callback handling loop
            while (isRunning)
            {
                // in order for the callbacks to get routed, they need to be handled by the manager
                manager.RunWaitCallbacks(TimeSpan.FromSeconds(1));
            }

            Console.WriteLine("Disconnecting from Steam...");

            Steam3.SteamUser.LogOff();
            Steam3.SteamClient.Disconnect();
            host.Stop();
            host.Stop();
        }
Esempio n. 3
0
 public Service StopHosting()
 {
     if (this.Started)
     {
         _host.Stop();
         this.Started = false;
     }
     return(this);
 }
 public void Stop()
 {
     if (null == TheNancyHost)
     {
         return;
     }
     TheNancyHost.Stop();
     TheNancyHost = null;
 }
        private void Restart()
        {
            //we stop the current host and dispose it then create a new one.
            //we do this in case the service is not authorised to run under the new user
            _NancyHost.Stop();
            _NancyHost.Dispose();

            _NancyHost = CreateHost();
            _NancyHost.Start();
        }
Esempio n. 6
0
        public void StartWebHost()
        {
            if (_WebHost != null)
            {
                _WebHost.Stop();
                _WebHost.Dispose();
            }
            string URL = "http://localhost";

            _WebHost = new NancyHost(new Uri(URL));
            _WebHost.Start();
        }
Esempio n. 7
0
        private void button3_Click(object sender, EventArgs e)
        {
            DialogResult result = MessageBox.Show("你确定要停止Nancy吗!", "提示信息", MessageBoxButtons.OKCancel, MessageBoxIcon.Information);

            if (result == DialogResult.OK)
            {
                if (_host != null)
                {
                    _host.Stop();
                    _host.Dispose();
                    _host = null;
                }
                MessageBox.Show("停止成功");
            }
        }
Esempio n. 8
0
        public static void Main(string[] args)
        {
            const string url = "http://localhost:8888";

            var uri        = new Uri(url);
            var hostConfig = new HostConfiguration
            {
                RewriteLocalhost = true,
                UrlReservations  = new UrlReservations {
                    CreateAutomatically = true
                }
            };
            var host = new NancyHost(hostConfig, uri);

            try
            {
                host.Start();
                Console.WriteLine("Nancy App Started");
            }
            catch (Exception ex)
            {
                Console.WriteLine($"Exception on start host: {ex.Message}{Environment.NewLine}{Environment.StackTrace}");
            }

            Console.ReadKey();
            host.Stop();
        }
Esempio n. 9
0
        static void Main(string[] args)
        {
            var ip = IpHelper.GetLocalIPAddress();

            try
            {
                using (var host = new NancyHost(
                           new Uri("http://127.0.0.1:" + ConfigurationManager.AppSettings["Port"].ToString())))
                //new Uri("http://" + ip + ":" + ConfigurationManager.AppSettings["Port"].ToString())))
                {
                    try
                    {
                        host.Start();
                        Console.WriteLine("Press any key to stop...");
                        Console.Read();
                        host.Stop();
                    }
                    catch (Exception ex)
                    {
                        Console.WriteLine(string.Format("Message:{0}, StackTrace:{1}", ex.Message, ex.StackTrace));
                        Console.ReadKey();
                    }
                }
            }
            catch (Exception ex)
            {
                Console.WriteLine(string.Format("Message:{0}, StackTrace:{1}", ex.Message, ex.StackTrace));
                Console.ReadKey();
            }
        }
Esempio n. 10
0
        private void StartServer_Click(object sender, EventArgs e)
        {
            if (isServerUp)
            {
                hostg.Stop();
                StartServer.Text = "Start Server";
                isServerUp       = false;
            }
            else
            {
                if (Globals.settings.tintEnabled)
                {
                    TintFolder("Content/html/img");
                    TintFolder("Content/html/img/pregame");
                }
                isServerUp = true;
                try
                {
                    UrlLinkLabel.Text = "http://127.0.0.1:" + Globals.settings.serverPort + "/Content/html/scoreboard.html";
                    HostConfiguration config = new HostConfiguration();
                    config.UrlReservations.CreateAutomatically = true;
                    NancyHost host = new NancyHost(config, new Uri("http://127.0.0.1:" + Globals.settings.serverPort));

                    host.Start();
                    hostg            = host;
                    StartServer.Text = "Stop Server";
                }
                catch (Exception ee)
                {
                    Console.WriteLine(ee.Message);
                    throw;
                }
            }
        }
Esempio n. 11
0
        public void Run(CancellationToken cancellationToken)
        {
            if (cancellationToken.IsCancellationRequested)
            {
                return;
            }

            var nancyConfig = new HostConfiguration
            {
                UrlReservations = new UrlReservations
                {
                    CreateAutomatically = true
                }
            };

            var bootstrapper = new ApiBootstrapper(_repository);

            var host = new NancyHost(bootstrapper, nancyConfig, _baseUri);

            cancellationToken.Register(() =>
            {
                Log.InfoFormat("Stopping Nancy host at \"{0}\".", _baseUri);
                host.Stop();
                Log.InfoFormat("Nancy host at \"{0}\" successfully stopped.", _baseUri);
            });

            Log.InfoFormat(CultureInfo.InvariantCulture, "Starting Nancy host at \"{0}\".", _baseUri);
            host.Start();
        }
        static void Main(string[] args)
        {
            InitializeEntityContext();
            InitializeTemplating();

            APPLICATION = new ApplicationModel();

            var uri = "http://localhost:8888";

            Console.WriteLine("Starting Nancy on " + uri + "\n Ctrl-C to Stop.");

            // initialize an instance of NancyHost
            HostConfiguration hostConfigs = new HostConfiguration();

            hostConfigs.UrlReservations.CreateAutomatically = true;
            var host = new NancyHost(new Uri(uri),
                                     new Bootstrapper(),
                                     hostConfigs);


            host.Start();              // start hosting

            RunWithoutInterface();

            Console.WriteLine("Stopping Nancy");
            host.Stop();              // stop hosting
        }
Esempio n. 13
0
 public void Stop()
 {
     _timer.Stop();
     _timer.Dispose();
     _host.Stop();
     Console.WriteLine("Stopped Client Viewer service...");
 }
Esempio n. 14
0
 public override void Shutdown()
 {
     if (Nancy != null)
     {
         Nancy.Stop();
     }
 }
Esempio n. 15
0
 static void Application_ApplicationExit(object sender, EventArgs e)
 {
     if (nancyHost != null)
     {
         nancyHost.Stop();
     }
 }
Esempio n. 16
0
        static void Main(string[] args)
        {
            Console.Write("Starting server...");

            ServicePointManager.ServerCertificateValidationCallback = AcceptAnyCertificate;

            var server = new NancyHost(new Uri("http://localhost:8282"));

            server.Start();
            Console.WriteLine("started!");

            if (Environment.OSVersion.Platform == PlatformID.Win32NT)
            {
                Console.WriteLine("press any key to exit");
                Console.ReadKey();
            }
            else
            {
                //Under mono if you deamonize a process a Console.ReadLine with cause an EOF
                //so we need to block another way
                Console.WriteLine("kill to exit");
                while (true)
                {
                    Thread.Sleep(10000000);
                }
            }

            server.Stop();              // stop hosting
        }
Esempio n. 17
0
        static void Main(string[] args)
        {
            Config = ConfigManager <ApiConfig> .LoadOrCreate();

            using (var host = new NancyHost(new ApiBootstrapper(), new HostConfiguration
            {
                UrlReservations = new UrlReservations
                {
                    CreateAutomatically = true
                }
            }, new Uri($"http://localhost:{Config.Port}")))
            {
                if (!OxideApi.Authenticate(Config.OxideUsername, Config.OxidePassword))
                {
                    Console.Error.WriteLine("Failed to authenticate with Oxide.");
                    return;
                }

                Console.WriteLine($"Starting api server on port {Config.Port}...");
                host.Start();

                Console.WriteLine("Press CTRL+Q to stop the server.");
                ConsoleKeyInfo consoleKeyInfo;
                while ((consoleKeyInfo = Console.ReadKey(true)).Key != ConsoleKey.Q || consoleKeyInfo.Modifiers != ConsoleModifiers.Control)
                {
                    continue;
                }

                Console.WriteLine("Stopping api server...");
                host.Stop();
            }
        }
Esempio n. 18
0
        static void Main(string[] args)
        {
            var uri = "http://localhost:8888";

            Logger.Info("Starting Nancy on " + uri);

            // initialize an instance of NancyHost
            var host = new NancyHost(new Uri(uri));

            host.Start();

            // check if we're running on mono
            if (Type.GetType("Mono.Runtime") != null)
            {
                // on mono, processes will usually run as daemons - this allows you to listen
                // for termination signals (ctrl+c, shutdown, etc) and finalize correctly
                UnixSignal.WaitAny(new[]
                {
                    new UnixSignal(Signum.SIGINT),
                    new UnixSignal(Signum.SIGTERM),
                    new UnixSignal(Signum.SIGQUIT),
                    new UnixSignal(Signum.SIGHUP)
                });
            }
            else
            {
                Console.ReadLine();
            }

            Logger.Info("Stopping Nancy");
            host.Stop();
        }
Esempio n. 19
0
        static void Main(string[] args)
        {
            try
            {
                //Uri uri = new Uri("http://localhost:4444/Connect4Challenge/");
                Uri uri = new Uri("http://localhost:4444/");
                using (var nancyHost = new NancyHost(new HostConfiguration {
                    UrlReservations = new UrlReservations {
                        CreateAutomatically = true
                    }
                }, uri))
                {
                    Console.WriteLine("Nancy now listening - navigating to " + uri.OriginalString);
                    nancyHost.Start();
                    Console.WriteLine("Press enter to stop");
                    Console.ReadKey();
                    nancyHost.Stop();
                }
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.ToString());
            }

            Console.WriteLine("Stopped. Good bye!");
            Console.ReadKey();
        }
Esempio n. 20
0
 private void Stop()
 {
     _nancyHost.Stop();
     _nancyHost.Dispose();
     _nancyHost = null;
     Console.WriteLine("HTTP server stopped");
 }
Esempio n. 21
0
 public bool Start(int port, int timeout = Timeout.Infinite, bool useDummyEV3 = false)
 {
     if (IsRunning)
     {
         Stop();
     }
     Port = port;
     serverStarted.Reset();
     EV3Module.EV3      = new EV3Model(useDummyEV3);
     EV3Module.Programs = new ProgramModelList(useDummyEV3);
     if (useDummyEV3)
     {
         EV3Module.LCD = new DummyLcdModel();
     }
     else
     {
         EV3Module.LCD = new LcdModel();
     }
     serverThread.Start();
     Console.WriteLine("Starting web server");
     if (!serverStarted.WaitOne(timeout))
     {
         Console.WriteLine("Start timeout");
         if (nancyHost != null)
         {
             nancyHost.Stop();
         }
         Stop();
     }
     System.Threading.Thread.Sleep(500);
     return(IsRunning);
 }
Esempio n. 22
0
        static void Main(string[] args)
        {
            const string serviceName  = "Practice";
            string       urlPortParam = args.Length == 0 ? "8001" : args[0];

            //var url = $"http://10.25.232.179:{urlPortParam}";

            var url = $"http://localhost:8001";

            var config = new HostConfiguration
            {
                RewriteLocalhost = true,
                UrlReservations  = new UrlReservations {
                    CreateAutomatically = true
                }
            };

            var host = new NancyHost(new Uri(url), new CustomBootstrapper(), config);

            host.Start();

            CustomBootstrapper.LoadInstanceInfoToDb(url);

            Console.WriteLine("{0} Running on {1}", serviceName, url);
            Console.WriteLine("Press enter to exit");
            Console.ReadLine();

            host.Stop();
        }
 private void Start()
 {
     _nancy.Start();
     Console.WriteLine($"Started listennig port {_port}");
     Console.ReadKey();
     _nancy.Stop();
 }
Esempio n. 24
0
        public static void Main(string[] args)
        {
            BasicConfigurator.Configure();

            var now = DateTime.UtcNow;

            var uri = "http://localhost:8888";

            Log.Info(log, "Starting MyRouter on " + uri, DateTime.UtcNow);

            // initialize an instance of NancyHost
            var host = new NancyHost(new Uri(uri));

            host.Start();  // start hosting

            // check if we're running on mono
            if (Type.GetType("Mono.Runtime") != null)
            {
                // on mono, processes will usually run as daemons - this allows you to listen
                // for termination signals (ctrl+c, shutdown, etc) and finalize correctly
                UnixSignal.WaitAny(new[] {
                    new UnixSignal(Signum.SIGINT),
                    new UnixSignal(Signum.SIGTERM),
                    new UnixSignal(Signum.SIGQUIT),
                    new UnixSignal(Signum.SIGHUP)
                });
            }
            else
            {
                System.Console.ReadLine();
            }

            Log.Info(log, "Stopping Nancy", DateTime.UtcNow);
            host.Stop();  // stop hosting
        }
Esempio n. 25
0
        public void Dispose()
        {
            nancyHost.Stop();

            signalrHost.Stop();
            signalrHost.Dispose();

            foreach (var site in sites.Values)
            {
                // update the site's copy of the model

                site.PageAdded        -= (sender, args) => HandleEvent(site.Name, args.WikiUrl);
                site.PageUpdated      -= (sender, args) => HandleEvent(site.Name, args.WikiUrl);
                site.PageDeleted      -= (sender, args) => HandleEvent(site.Name, args.WikiUrl);
                site.PageMoved        -= (sender, args) => HandleEvent(site.Name, args.WikiUrl);
                site.DirectoryAdded   -= (sender, args) => HandleEvent(site.Name, args.WikiUrl);
                site.DirectoryUpdated -= (sender, args) => HandleEvent(site.Name, args.WikiUrl);
                site.DirectoryDeleted -= (sender, args) => HandleEvent(site.Name, args.WikiUrl);
                site.DirectoryMoved   -= (sender, args) => HandleEvent(site.Name, args.WikiUrl);

                site.Dispose();
            }

            sites = null;
        }
Esempio n. 26
0
        static void Main(string[] args)
        {
            string _url  = "http://localhost";
            int    _port = 12345;
            var    uri   = new Uri($"{_url}:{_port}/");


            var configuration = new HostConfiguration()
            {
                UrlReservations = new UrlReservations()
                {
                    CreateAutomatically = true
                }
            };

            var host = new NancyHost(configuration, uri);

            host.Start(); // start hosting

            Console.WriteLine($"Started listennig port {_port}");
            Console.WriteLine($"URL {_url}:{_port}/");



            Console.WriteLine("Press any key to exit.");
            Console.ReadKey();
            host.Stop();  // stop hosting
        }
        static void Main(string[] args)
        {
            String consoleInput;
            var    uri    = new Uri("http://localhost:55555/");
            var    config = new HostConfiguration
            {
                // This makes it so that we don't have to manually reserve the URL on windows
                UrlReservations = new UrlReservations()
                {
                    CreateAutomatically = true
                },
                RewriteLocalhost = true
            };
            var startupMessage = new StringBuilder("Running on ");

            startupMessage.AppendFormat("{0}. Use {1} to shut down the server.", uri.ToString(), exitCode);
            var host = new NancyHost(config, uri);

            try
            {
                host.Start();
                Console.WriteLine(startupMessage);

                do
                {
                    consoleInput = Console.ReadLine();
                } while (!consoleInput.Equals(exitCode));
                host.Stop();
            }
            catch (Exception ex)
            {
                Console.WriteLine("Unknown error has occurred. See below: \n" + ex.ToString());
            }
        }
Esempio n. 28
0
        static void Main(string[] args)
        {
            using (IUserRepository ctx = NinjectKernel.Get <IUserRepository>())
            {
                ctx.Add(new RegistrationUser()
                {
                    Id       = Guid.NewGuid(),
                    IsAdmin  = true,
                    Password = "******",
                    UserName = "******"
                });
                ctx.SaveChanges();
            }



            NancyHost Host = new NancyHost(new HostConfiguration()
            {
                UrlReservations = new UrlReservations()
                {
                    CreateAutomatically = true
                },
                AllowChunkedEncoding = false
            }, new Uri("http://localhost:9900"));

            Host.Start();
            Console.WriteLine("Server started");
            Console.ReadLine();
            Host.Stop();
            Console.WriteLine("Server stoped");
        }
Esempio n. 29
0
        private static void Main(string[] args)
        {
            var uri = "http://localhost:8900";

            StaticConfiguration.DisableErrorTraces = false;
            using (var host = new NancyHost(new HostConfiguration {
                UrlReservations = new UrlReservations {
                    CreateAutomatically = true
                }
            }, new Uri(uri)))
            {
                host.Start();
                if (Type.GetType("Mono.Runtime") != null)
                {
                    UnixSignal.WaitAny(new[]
                    {
                        new UnixSignal(Signum.SIGINT),
                        new UnixSignal(Signum.SIGTERM),
                        new UnixSignal(Signum.SIGQUIT),
                        new UnixSignal(Signum.SIGHUP)
                    });
                }
                else
                {
                    Console.WriteLine(string.Format("I'm a runnin' on {0}", uri));
                    Console.ReadKey();
                }
                host.Stop();
            }
        }
Esempio n. 30
0
        private static void Main(string[] args)
        {
            using (var container = Bootstrap())
            {
#if !DEBUG
                try
#endif
                {
                    Trace.Listeners.Add(new ConsoleTraceListener());

                    if (args.Length > 0 && args[0] == "--build-index")
                    {
                        var indexer = container.Resolve <MusicIndexer>();
                        indexer.IndexFolder(Settings.Default.LibraryFolder);
                        return;
                    }

                    using (var nancyHost = new NancyHost(new NancyBootstrapper(container), new Uri(Settings.Default.BaseAddress)))
                    {
                        nancyHost.Start();
                        Console.ReadKey();
                        nancyHost.Stop();
                    }
                }
#if !DEBUG
                catch (Exception e)
                {
                    Trace.WriteLine("Unexpected fatal error, the server was shutdown: " + e.Message);
                }
#endif
            }
        }
Esempio n. 31
0
 static void Main(string[] args)
 {
     var nancyHost = new NancyHost(new Uri("http://localhost:8888/nancy/"));
     nancyHost.Start();
     Console.WriteLine("Nancy now listening - navigate to http://localhost:8888/nancy/. Press enter to stop");
     Console.ReadKey();
     nancyHost.Stop();
     Console.WriteLine("Stopped. Good bye!");
 }