public static void Release(HostPool pool) { lock (_poolsLock) { _pools.Add(pool); } }
public static HostPool GetHost(IPEndPoint endPoint) { lock (_poolsLock) { var pool = _pools .FirstOrDefault(p => p.EndPoint == endPoint); if (pool == null) { pool = new HostPool(endPoint); } else { _pools.Remove(pool); } return(pool); } }
public void Dispose() { var request = new MessageRequest { Commands = new ICommand[] { new ReleaseConnectionCommand() } }; var response = SendMessage(request).Result; if (!string.IsNullOrEmpty(response.Error)) { //TODO: tratar erro ao soltar a connection } _host.Release(); _host = null; }
public ClientConnection(IPEndPoint endPoint) { _host = HostStorage.GetHost(endPoint); _idsIndex = 0; }