using System; using System.Net.Sockets; namespace Ion.Net.Connections { /// /// A factory for creating IonTcpConnections. /// public class IonTcpConnectionFactory { #region Fields /// /// A 32 bit unsigned integer that is incremented everytime a connection is added. /// private uint mConnectionCounter; #endregion #region Properties /// /// Gets the total amount of created connections. /// public uint Count { get { return mConnectionCounter; } } #endregion #region Methods /// /// Creates an IonTcpConnection instance for a given socket and assigns it an unique ID. /// /// The System.Net.Socket.Sockets object to base the connection on. /// IonTcpConnection public IonTcpConnection CreateConnection(Socket pSocket) { if (pSocket == null) return null; IonTcpConnection connection = new IonTcpConnection(++mConnectionCounter, pSocket); IonEnvironment.GetLog().WriteInformation(string.Format("Created IonTcpConnection [{0}] for {1}.", connection.ID, connection.ipAddress)); return connection; } #endregion } }