Example #1
0
        private static void Main()
        {
            LogFactory.OnWrite += Manager.Log.LogFactory_ConsoleWrite;
start:
            try
            {
                Settings.Initialize();

                AutoRestartTIme = Settings.GetInt("MsgServer/AutoRestartTime");

                Clients = new GCClients();

                Handlers = new HandlerStore <GCClient>();
                Handlers.Cache();

                Database.Test();
                Database.Analyze();

                RemoteEndPoint = new IPEndPoint(Settings.GetIPAddress("MsgServer/ExternalIP"), Settings.GetInt("MsgServer/Port"));

                Listener = new TcpListener(IPAddress.Any, Server.RemoteEndPoint.Port);
                Listener.Start();
                LogFactory.GetLog("Main").LogInfo("Socket Open : {0}.", Server.Listener.LocalEndpoint);

                IsAlive = true;
            }
            catch (Exception e)
            {
                LogFactory.GetLog("Main").LogFatal(e);
            }

            if (Server.IsAlive)
            {
                LogFactory.GetLog("Main").LogSuccess("O servidor foi aberto com sucesso ID : {0}.", Thread.CurrentThread.ManagedThreadId);
            }
            else
            {
                LogFactory.GetLog("Main").LogInfo("Ocorreu um erro e o servidor não está aberto.");
            }

            while (Server.IsAlive)
            {
                Server.AcceptDone.Reset();

                Server.Listener.BeginAcceptSocket(new AsyncCallback(Server.OnAcceptSocket), null);

                Server.AcceptDone.WaitOne();
            }

            GCClient[] remainingClients = Server.Clients.ToArray();

            foreach (GCClient client in remainingClients)
            {
                client.Close();
            }

            Server.Dispose();

            LogFactory.GetLog("Main").LogWarning("O servidor foi parado.");

            if (Server.AutoRestartTIme > 0)
            {
                LogFactory.GetLog("Main").LogInfo("Servidor {0} segundos será reiniciado automaticamente.", Server.AutoRestartTIme);

                Thread.Sleep(Server.AutoRestartTIme * 1000);

                goto start;
            }
            else
            {
                Console.Read();
            }
        }
Example #2
0
        private static void Main()
        {
            LogFactory.OnWrite += Log.LogFactory_ConsoleWrite;

start:
            LogFactory.GetLog("Main").LogSuccess("Grand Chase Season 5 / Servidor de Jogo");
            try
            {
                Settings.Initialize();

                AutoRestartTIme = Settings.GetInt("GameServer/AutoRestartTime");
                LogFactory.GetLog("Main").LogInfo("reinicializaçao automatica do servidor é definido como {0} segundos.", Server.AutoRestartTIme);

                UDPRelayIP    = Settings.GetString("GameServer/UDPRelayIP");
                UDPRelayPort  = Settings.GetShort("GameServer/UDPRelayPort");
                TCPRelayIP    = Settings.GetString("GameServer/TCPRelayIP");
                TCPRelayPort  = Settings.GetShort("GameServer/TCPRelayPort");
                MsgServerIP   = Settings.GetString("GameServer/MsgServerIP");
                MsgServerPort = Settings.GetShort("GameServer/MsgServerPort");

                TSingleton <ChannelManager> .Instance.AddChannel("대전", 2000, 0);

                TSingleton <ChannelManager> .Instance.AddChannel("던전", 2000, 0);

                Clients = new GCClients();
                LogFactory.GetLog("Main").LogInfo("Criando lista de clientes objetos");

                Handlers = new HandlerStore <GCClient>();
                Handlers.Cache();

                Database.Test();
                Database.Analyze();
                LogFactory.GetLog("Starting GoodsInfoList").LogInfo("Wait....");
                goodsList.LoadShop();
                LogFactory.GetLog("Shop Carregado Total de IDs encontrados: ").LogInfo("" + goodsList.goodsIttems.Length);

                RemoteEndPoint = new IPEndPoint(Settings.GetIPAddress("GameServer/ExternalIP"), Settings.GetInt("GameServer/Port"));

                Listener = new TcpListener(IPAddress.Any, Server.RemoteEndPoint.Port);
                Listener.Start();
                LogFactory.GetLog("Main").LogInfo("conexao socket iniciada. porta: {0}.", Server.Listener.LocalEndpoint);

                IsAlive = true;
            }
            catch (Exception e)
            {
                LogFactory.GetLog("Main").LogFatal(e);
            }

            if (Server.IsAlive)
            {
                LogFactory.GetLog("Main").LogInfo("o servidor foi aberto com sucesso. a identificaçao do segmento : {0}.", Thread.CurrentThread.ManagedThreadId);
            }
            else
            {
                LogFactory.GetLog("Main").LogInfo("o servidor nao foi iniciado com sucesso.");
            }

            while (Server.IsAlive)
            {
                Server.AcceptDone.Reset();

                Server.Listener.BeginAcceptSocket(new AsyncCallback(Server.OnAcceptSocket), null);

                Server.AcceptDone.WaitOne();
            }

            GCClient[] remainingClients = Server.Clients.ToArray();

            foreach (GCClient client in remainingClients)
            {
                client.Close();
            }

            Server.Dispose();

            LogFactory.GetLog("Main").LogWarning("O servidor foi interrompida.");

            if (Server.AutoRestartTIme > 0)
            {
                LogFactory.GetLog("Main").LogInfo("Servidor {0} segundos será reiniciado automaticamente.", Server.AutoRestartTIme);

                Thread.Sleep(Server.AutoRestartTIme * 1000);

                goto start;
            }
            else
            {
                Console.Read();
            }
        }
Example #3
0
        private static void Main()
        {
            Console.Title = "Z Team Studio - CenterServer";
            bool socketss = true;

            if (socketss == true)
            {
                LogFactory.OnWrite += Manager.Log.LogFactory_ConsoleWrite;
                Console.WriteLine("Pressione Enter Para Iniciar o Servidor");
                Console.Clear();
start:
                try
                {
                    Settings.Initialize();

                    AutoRestartTIme = Settings.GetInt("CenterServer/AutoRestartTime");
                    LogFactory.GetLog("Main").LogInfo("Reinicio Automatico do Servidor: {0} Segundos.", Server.AutoRestartTIme);

                    Clients = new GCClients();
                    LogFactory.GetLog("Main").LogInfo("Criando lista de clientes");

                    Handlers = new HandlerStore <GCClient>();
                    Handlers.Cache();

                    Database.Test();
                    Database.Analyze();


                    Shop shop = new Shop();

                    LogFactory.GetLog("Shop").LogWarning("Carregando Items");
                    shop.SendShop();
                    LogFactory.GetLog("Shop").LogWarning("Items Carregados,Total: " + shop.goodsIttems.Length);

                    RemoteEndPoint = new IPEndPoint(Settings.GetIPAddress("CenterServer/ExternalIP"), Settings.GetInt("CenterServer/Port"));

                    Listener = new TcpListener(IPAddress.Any, Server.RemoteEndPoint.Port);
                    Listener.Start();
                    Loading loading = new Loading();

                    // loading.addcheck("main2.exe","A42B77BEEECE321B19257C7EE803548B9DFD7A42");
                    //loading.addcheck("script.exe", "A42B77BEEECE321B19257C7EE803548B9DFD7A42");


                    LogFactory.GetLog("Main").LogInfo("threads Iniciada, Porta: {0}.", Server.Listener.LocalEndpoint);

                    IsAlive = true;
                }
                catch (Exception e)
                {
                    LogFactory.GetLog("Main").LogFatal(e);
                }

                if (Server.IsAlive)
                {
                    LogFactory.GetLog("Main").LogSuccess("O servidor foi aberto com sucesso. threads : {0}.", Thread.CurrentThread.ManagedThreadId);
                }
                else
                {
                    LogFactory.GetLog("Main").LogInfo("Occoreu um Erro Servidor nao foi iniciado.");
                }

                while (Server.IsAlive)
                {
                    Server.AcceptDone.Reset();

                    Server.Listener.BeginAcceptSocket(new AsyncCallback(Server.OnAcceptSocket), null);

                    Server.AcceptDone.WaitOne();
                }

                GCClient[] remainingClients = Server.Clients.ToArray();

                foreach (GCClient client in remainingClients)
                {
                    client.Close();
                }

                Server.Dispose();

                LogFactory.GetLog("Main").LogWarning("Servidor foi Interrompido.");

                if (Server.AutoRestartTIme > 0)
                {
                    LogFactory.GetLog("Main").LogInfo("O Servidor Reiniciara daqui a {0} segundos .", Server.AutoRestartTIme);

                    Thread.Sleep(Server.AutoRestartTIme * 1000);

                    goto start;
                }
                else
                {
                    Console.Read();
                }
            }
        }
Example #4
0
        private static void Main()
        {
            Console.Title       = "Zteam Studio GameServer";
            LogFactory.OnWrite += Log.LogFactory_ConsoleWrite;
start:
            try
            {
                Settings.Initialize();

                AutoRestartTIme = Settings.GetInt("GameServer/AutoRestartTime");
                LogFactory.GetLog("Main").LogInfo("reinicializaçao automatica do servidor é definido como {0} segundos.", Server.AutoRestartTIme);

                UDPRelayIP    = Settings.GetString("GameServer/UDPRelayIP");
                UDPRelayPort  = Settings.GetShort("GameServer/UDPRelayPort");
                TCPRelayIP    = Settings.GetString("GameServer/TCPRelayIP");
                TCPRelayPort  = Settings.GetShort("GameServer/TCPRelayPort");
                MsgServerIP   = Settings.GetString("GameServer/MsgServerIP");
                MsgServerPort = Settings.GetShort("GameServer/MsgServerPort");

                TSingleton <ChannelManager> .Instance.AddChannel("대전", 2000, 0);

                TSingleton <ChannelManager> .Instance.AddChannel("던전", 2000, 0);

                Clients = new GCClients();
                LogFactory.GetLog("Main").LogInfo("Criando lista de clientes objetos");

                Handlers = new HandlerStore <GCClient>();
                Handlers.Cache();

                Database.Test();
                Database.Analyze();

                LogFactory.GetLog("Shop").LogInfo("Carregando Items da DB");
                Shop shop = new Shop();

                shop.LoadShop();
                LogFactory.GetLog("Shop").LogInfo("Items Carregads, Total: " + shop.goodsIttems.Length);

                LogFactory.GetLog("Hero Dungeon").LogInfo("Carregando Lista De Hero!");

                GCCommon MyCommon = new GCCommon();

                MyCommon.LoadHero();
                LogFactory.GetLog("Hero Dungeon").LogInfo("Hero Dungeon Carreda!,Total: " + MyCommon.herodungeon.Length);

                RemoteEndPoint = new IPEndPoint(Settings.GetIPAddress("GameServer/ExternalIP"), Settings.GetInt("GameServer/Port"));

                Listener = new TcpListener(IPAddress.Any, Server.RemoteEndPoint.Port);
                Listener.Start();
                LogFactory.GetLog("Main").LogInfo("conexao socket iniciada. porta: {0}.", Server.Listener.LocalEndpoint);

                User.StatusOnline(null, null, 0, 2);

                IsAlive = true;
            }
            catch (Exception e)
            {
                LogFactory.GetLog("MAIN").LogFatal(e);
            }

            if (Server.IsAlive)
            {
                LogFactory.GetLog("Main").LogInfo("o servidor foi aberto com sucesso. a identificaçao do segmento : {0}.", Thread.CurrentThread.ManagedThreadId);
            }
            else
            {
                LogFactory.GetLog("Main").LogInfo("o servidor nao foi iniciado com sucesso.");
            }

            while (Server.IsAlive)
            {
                Server.AcceptDone.Reset();

                Server.Listener.BeginAcceptSocket(new AsyncCallback(Server.OnAcceptSocket), null);

                Server.AcceptDone.WaitOne();
            }

            GCClient[] remainingClients = Server.Clients.ToArray();

            foreach (GCClient client in remainingClients)
            {
                client.Close();
            }

            Server.Dispose();

            LogFactory.GetLog("Main").LogWarning("Error ");

            if (Server.AutoRestartTIme > 0)
            {
                Thread.Sleep(Server.AutoRestartTIme * 1000);

                goto start;
            }
            else
            {
                Console.Read();
            }
            {
                return;
            }
        }