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); }
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); }
protected abstract NetworkServerConfig CheckConfig( NetworkServerConfig config);
public abstract bool Open(NetworkServerConfig config);
protected override NetworkServerConfig CheckConfig(NetworkServerConfig config) { config.MaxClientsPerIp = Math.Clamp(config.MaxClientsPerIp, 1, config.MaxClients); return(config); }
protected override NetworkServerConfig CheckConfig(NetworkServerConfig config) { return(config); }