Removed leftovers.

This commit is contained in:
flash 2025-05-03 02:55:06 +00:00
parent 5a7756894b
commit 26e756525e
Signed by: flash
GPG key ID: 2C9C2C574D47FE3E

View file

@ -1,40 +0,0 @@
using SharpChat.Snowflake;
using System.Net;
namespace SharpChat.Connections;
public class ConnectionsContext {
private readonly Dictionary<long, Connection> Connections = [];
private readonly Lock @lock = new();
public Connection? GetConnection(long connId) {
lock(@lock)
return Connections.TryGetValue(connId, out Connection? conn) ? conn : null;
}
public IEnumerable<Connection> GetConnections() {
lock(@lock)
return [.. Connections.Values];
}
public IEnumerable<Connection> GetConnections(IEnumerable<long> ids) {
return [.. ids.Select(GetConnection).Where(c => c is not null).Cast<Connection>()];
}
public IEnumerable<Connection> GetConnections(Func<Connection, bool> predicate) {
lock(@lock)
return [.. Connections.Values.Where(predicate)];
}
public IEnumerable<T> GetConnectionsOfType<T>() where T : Connection {
return GetConnections(c => c is T).Cast<T>();
}
public IEnumerable<IPEndPoint> GetRemoteEndPoints() {
return GetConnections().Select(c => c.RemoteEndPoint).Distinct();
}
public IEnumerable<IPEndPoint> GetRemoteEndPoints(Func<Connection, bool> predicate) {
return GetConnections(predicate).Select(c => c.RemoteEndPoint).Distinct();
}
}