using System; using System.Net.Sockets; namespace Uber.Net { /// /// A factory for creating IonTcpConnections. /// public class TcpConnectionFactory { #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 TcpConnection CreateConnection(Socket pSocket) { if (pSocket == null) return null; TcpConnection connection = new TcpConnection(++mConnectionCounter, pSocket); UberEnvironment.GetLogging().WriteInformation(string.Format("Created IonTcpConnection [{0}] for {1}.", connection.ID, connection.ipAddress)); return connection; } #endregion } }