Ejemplo n.º 1
0
        static LocalClientBase StartLocalWorldServer()
        {
            WorldServerConfig config = new WorldServerConfig(m_configDir + "worldserver.config");

            if (config.Document["WorldServerConfig"] == null)
            {
                config.SetDefaultValues();
            }

            XmlNodeList list = config.Document["WorldServerConfig"].SelectNodes("descendant::ScriptReference");

            foreach (XmlNode node in list)
            {
                WorldServer.AddScriptReference(node.InnerText);
            }

            if (WorldServer.LoadWorldScripts(config.Scripts) == false)
            {
                return(null);
            }
            LocalClientBase c1 = new LocalClientBase();
            LocalClientBase c2 = new LocalClientBase();

            c1.SetRemoteClient(c2);
            c2.SetRemoteClient(c1);
            WorldServer.Start(c2);
            localWorldServerStarted = true;
            Console.WriteLine("Local Worldserver started.");
            return(c1);
        }
Ejemplo n.º 2
0
        static bool StartWorldServer()
        {
            WorldServerConfig config = new WorldServerConfig(m_configDir + "worldserver.config");

            if (config.Document["WorldServerConfig"] == null)
            {
                config.SetDefaultValues();
            }

            XmlNodeList list = config.Document["WorldServerConfig"].SelectNodes("descendant::ScriptReference");

            foreach (XmlNode node in list)
            {
                WorldServer.AddScriptReference(node.InnerText);
            }

            if (!WorldServer.LoadWorldScripts(config.Scripts))
            {
                return(false);
            }
            IPAddress address = GetAddress(config.Address);
            int       port    = config.Port;

            if (port == 0)
            {
                port = 9003;
            }
            Socket     listen = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp);
            ClientBase client;

            try
            {
                listen.Bind(new IPEndPoint(address, port));
                listen.Listen(1);
                Console.WriteLine("Waiting for loginserver to connect on " + listen.LocalEndPoint);
                Socket sock = listen.Accept();
                Console.WriteLine("Loginserver connected from " + sock.RemoteEndPoint);
                listen.Close();
                client = new ClientBase(sock);
            }
            catch (Exception e)
            {
                Console.WriteLine("Worldserver listening socket failed. " + e.Message);
                return(false);
            }
            WorldServer.Start(client);
            Console.WriteLine("Worldserver started.");
            return(true);
        }