Exemplo n.º 1
0
 private void SendGameServerData(ByteBuffer msg)
 {
     if (TcpTransfer.Connected)
     {
         TcpTransfer.Send(msg);
     }
 }
Exemplo n.º 2
0
        public void InitServer()
        {
            Configuration.Open();
            Configuration.GetGeneralConfig();
            Configuration.GetDatabaseConfig();
            Configuration.Close();

            Configuration.ShowConfigInLog();
            Configuration.CheckDatabaseConnection();

            if (GeoIpBlock.Enabled)
            {
                WriteLog(LogType.System, "Loading GeoIp data country", LogColor.Black);
                GeoIpBlock.LoadData();
            }

            IpBlockList.Initialize();

            IpFiltering = new IpFiltering()
            {
                CheckAccessTime  = Configuration.CheckAccessTime,
                IpLifetime       = Configuration.IpLifetime,
                IpMaxAccessCount = Configuration.IpMaxAccessCount,
                IpMaxAttempt     = Configuration.IpMaxAttempt
            };

            WriteLog(LogType.System, "Initializing scripts", LogColor.Blue);

            var lua = new LuaScript();

            lua.InitializeScript();

            OpCode.Initialize();

            TcpTransfer = new TcpTransfer()
            {
                GameIpAddress = Configuration.GameServerIp,
                GamePort      = Configuration.GameServerPort
            };

            TcpTransfer.InitClient();

            WriteLog(LogType.System, "Trying to connect to Game Server", LogColor.Black);

            Server = new TcpServer()
            {
                IpFiltering = IpFiltering,
                Port        = Configuration.Port
            };

            Server.InitServer();

            // Delegate
            SendGameServerPacket = SendGameServerData;

            WriteLog(LogType.System, "Login Server started", LogColor.Green);
        }
Exemplo n.º 3
0
        public void ServerLoop()
        {
            TcpTransfer.Connect();
            TcpTransfer.SendPing();

            Server.AcceptClient();
            Server.ProcessClients();

            IpBlockList.RemoveExpiredIpAddress();
            IpFiltering.RemoveExpiredIpAddress();

            CountUps();
        }
Exemplo n.º 4
0
        public void StopServer()
        {
            Server.Stop();

            TcpTransfer.Disconnect();
            TcpTransfer = null;

            IpFiltering.Clear();

            Checksum.Clear();
            GeoIpBlock.Clear();
            IpBlockList.Clear();

            CloseLog();
        }