123456789101112131415161718192021222324252627282930313233343536373839404142434445 |
- using System;
- using System.Collections.Generic;
- using Utilities;
- namespace SMBLibrary.Server
- {
- internal class ConnectionManager
- {
- private List<ConnectionState> m_activeConnections = new List<ConnectionState>();
- public void AddConnection(ConnectionState connection)
- {
- lock (m_activeConnections)
- {
- m_activeConnections.Add(connection);
- }
- }
- public bool RemoveConnection(ConnectionState connection)
- {
- lock (m_activeConnections)
- {
- int connectionIndex = m_activeConnections.IndexOf(connection);
- if (connectionIndex >= 0)
- {
- m_activeConnections.RemoveAt(connectionIndex);
- return true;
- }
- return false;
- }
- }
- public void ReleaseConnection(ConnectionState connection)
- {
- SocketUtils.ReleaseSocket(connection.ClientSocket);
- RemoveConnection(connection);
- }
- }
- }
|