Пример #1
0
        /// <summary>
        /// Constructs an instance of IonTcpConnectionManager, constructs an IonTcpConnectionListener, binds it to a given local IP and TCP port and sets the maximum amount of connections.
        /// </summary>
        /// <param name="sLocalIP">The local IP address to bind the listener to.</param>
        /// <param name="Port">The TCP port number to bind the listener to.</param>
        /// <param name="maxSimultaneousConnections">The maximum amount of connections in the Connection manager.</param>
        public IonTcpConnectionManager(string sLocalIP, int Port, int maxSimultaneousConnections)
        {
            int initialCapacity = maxSimultaneousConnections;
            if (maxSimultaneousConnections > 4)
                initialCapacity /= 4; // Set 1/4 of max connections as initial capacity to avoid too much resizing

            mConnections = new Dictionary<uint, IonTcpConnection>(initialCapacity);
            mMaxSimultaneousConnections = maxSimultaneousConnections;

            mListener = new IonTcpConnectionListener(sLocalIP, Port, this);
        }
Пример #2
0
 /// <summary>
 ///   Destroys all resources in the Connection manager.
 /// </summary>
 public void DestroyManager()
 {
     _connections.Clear();
     _connections = null;
     _listener    = null;
 }
Пример #3
0
        /// <summary>
        ///   Constructs an instance of IonTcpConnectionManager, constructs an IonTcpConnectionListener, binds it to a given local IP and TCP port and sets the maximum amount of connections.
        /// </summary>
        /// <param name = "localIP">The local IP address to bind the listener to.</param>
        /// <param name = "port">The TCP port number to bind the listener to.</param>
        /// <param name = "maxSimultaneousConnections">The maximum amount of connections in the Connection manager.</param>
        public IonTcpConnectionManager(string localIP, int port)
        {
            _connections = new Dictionary <uint, IonTcpConnection>();

            _listener = new IonTcpConnectionListener(localIP, port, this);
        }
Пример #4
0
 /// <summary>
 /// Destroys all resources in the Connection manager.
 /// </summary>
 public void DestroyManager()
 {
     mConnections.Clear();
     mConnections = null;
     mListener = null;
 }