mirror of https://github.com/ogoun/Zero.git
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
33 lines
790 B
33 lines
790 B
using System.Collections.Generic;
|
|
using System.Net;
|
|
using ZeroLevel.Services.Collections;
|
|
|
|
namespace ZeroLevel.Services.Network.Proxies
|
|
{
|
|
internal sealed class ProxyBalancer
|
|
{
|
|
private RoundRobinCollection<IPEndPoint> _servers;
|
|
|
|
public ProxyBalancer()
|
|
{
|
|
_servers = new RoundRobinCollection<IPEndPoint>();
|
|
}
|
|
|
|
public ProxyBalancer(IEnumerable<IPEndPoint> endpoints)
|
|
{
|
|
_servers = new RoundRobinCollection<IPEndPoint>(endpoints);
|
|
}
|
|
|
|
public void AddEndpoint(IPEndPoint ep) => _servers.Add(ep);
|
|
|
|
public IPEndPoint GetServerProxy()
|
|
{
|
|
if (_servers.MoveNext())
|
|
{
|
|
return _servers.Current;
|
|
}
|
|
return null;
|
|
}
|
|
}
|
|
}
|