Removed leftovers.
This commit is contained in:
parent
5a7756894b
commit
26e756525e
1 changed files with 0 additions and 40 deletions
|
@ -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();
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue