public override void Update(Server server, float dt)
    {
        if (!started)
        {
            started = true;

            int httpPort = server.Port + 1;
            if (server.config.EnableHTTPServer && (!server.IsSinglePlayer))
            {
                try
                {
                    httpServer = new FragLabs.HTTP.HttpServer(new IPEndPoint(IPAddress.Any, httpPort));
                    MainHttpModule m = new MainHttpModule();
                    m.server = server;
                    m.system = this;
                    httpServer.Install(m);
                    foreach (var module in server.httpModules)
                    {
                        httpServer.Install(module.module);
                    }
                    httpServer.Start();
                    Console.WriteLine(server.language.ServerHTTPServerStarted(), httpPort);
                }
                catch
                {
                    Console.WriteLine(server.language.ServerHTTPServerError(), httpPort);
                }
            }
        }
        for (int i = 0; i < server.httpModules.Count; i++)
        {
            ActiveHttpModule m = server.httpModules[i];
            if (httpServer != null)
            {
                if (!m.installed)
                {
                    m.installed = true;
                    httpServer.Install(m.module);
                }
            }
        }
    }
Exemple #2
0
    public override void Update(Server server, float dt)
    {
        if (!started)
        {
            started = true;

            int httpPort = server.Port + 1;
            if (server.config.EnableHTTPServer && (!server.IsSinglePlayer))
            {
                try
                {
                    httpServer = new FragLabs.HTTP.HttpServer(new IPEndPoint(IPAddress.Any, httpPort));
                    MainHttpModule m = new MainHttpModule();
                    m.server = server;
                    m.system = this;
                    httpServer.Install(m);
                    foreach (var module in server.httpModules)
                    {
                        httpServer.Install(module.module);
                    }
                    httpServer.Start();
                    Console.WriteLine(server.language.ServerHTTPServerStarted(), httpPort);
                }
                catch
                {
                    Console.WriteLine(server.language.ServerHTTPServerError(), httpPort);
                }
            }
        }
        for (int i = 0; i < server.httpModules.Count; i++)
        {
            ActiveHttpModule m = server.httpModules[i];
            if (httpServer != null)
            {
                if (!m.installed)
                {
                    m.installed = true;
                    httpServer.Install(m.module);
                }
            }
        }
    }