예제 #1
0
        public override bool Open(NetworkServerConfig config)
        {
            if (!NetworkCore.CreateUdpClient(config.LocalEndPoint, out var socket))
            {
                return(false);
            }

            ServerConfig = CheckConfig(config);
            UdpClient    = socket;
            Connections  = new BaseNetworkConnection[ServerConfig.MaxClients];

            for (var i = 0; i < Salts.Length; i++)
            {
                Secure.RandomFill(Salts[i]);
            }

            LastSaltUpdate       = Time.Get();
            LegacyRateLimitStart = -1;
            LegacyRateLimitNum   = 0;

            for (var i = 0; i < Connections.Length; i++)
            {
                Connections[i] = Kernel.Get <BaseNetworkConnection>();
                Connections[i].Init(UdpClient);
            }

            return(true);
        }
예제 #2
0
        public override bool Open(NetworkServerConfig config)
        {
            if (!NetworkHelper.UdpClient(config.BindEndPoint, out var socket))
            {
                return(false);
            }

            UdpClient = socket;
            TokenManager.Init(UdpClient);
            TokenCache.Init(UdpClient, TokenManager);

            Config      = CheckConfig(config);
            Connections = new BaseNetworkConnection[Config.MaxClients];

            for (var i = 0; i < Connections.Count; i++)
            {
                Connections[i] = Kernel.Get <BaseNetworkConnection>();
                Connections[i].Init(UdpClient, Config.ConnectionConfig);
            }

            return(true);
        }
예제 #3
0
 protected abstract NetworkServerConfig CheckConfig(
     NetworkServerConfig config);
예제 #4
0
 public abstract bool Open(NetworkServerConfig config);
예제 #5
0
 protected override NetworkServerConfig CheckConfig(NetworkServerConfig config)
 {
     config.MaxClientsPerIp = Math.Clamp(config.MaxClientsPerIp, 1, config.MaxClients);
     return(config);
 }
예제 #6
0
 protected override NetworkServerConfig CheckConfig(NetworkServerConfig config)
 {
     return(config);
 }