/// <summary>
        /// Closes active <see cref="UserConnection"/>.
        /// </summary>
        /// <param name="connection"><see cref="UserConnection"/> object, which network must be closed.</param>
        internal static void CloseActiveConnection( UserConnection connection )
        {
            if ( connection != null )
            {
                connection.CloseConnection();

                if ( connection.Session.AccountID > 0 )
                    CacheServiceConnection.Send(new UnCacheUser(connection.Session.ID).ToPacket());

                m_ActiveConnections.Remove(connection.Session.ID);

                Logger.WriteLine(Source.OuterNetwork, "Connection closed for session {0}.", connection.Session.ToString());

                connection = null;
            }
        }
        /// <summary>
        /// Executes after listener accepted new connection.
        /// </summary>
        /// <param name="socket">New connection socket.</param>
        private static void ListenerService_OnConnectionAccepted( Socket socket )
        {
            if ( socket != null && socket.Connected )
            {
                UserConnection userConnection = new UserConnection(socket);

                //if ( m_ActiveConnections.Count >= Settings.Default.LoginServiceMaxAwaitingUsersCount )
                //{
                //    userConnection.Send(ServerPackets.LoginFailed(UserAuthenticationResponseType.ServerOverloaded));
                //    CloseActiveConnection(userConnection);
                //    return;
                //}

                /*if ( m_ActiveConnections.ContainsKey(userConnection.Session.ID) )
                {
                    userConnection = null;
                    ListenerService_OnConnectionAccepted(socket);
                    return;
                }*/

                //m_ActiveConnections.Add(userConnection.Session.ID, userConnection);

                //userConnection.Send(ServerPackets.InitializeConnection(userConnection.Session)); // say hello to client

                //userConnection.BeginReceive();
            }
        }
        /// <summary>
        /// Removes provided <see cref="UserConnection"/> object from active connections list.
        /// </summary>
        /// <param name="connection"><see cref="UserConnection"/> object to remove from active connections list.</param>
        internal static void RemoveFromActiveConnections( UserConnection connection )
        {
            if ( connection != null )
            {
                if ( connection.Session.AccountID > 0 )
                    CacheServiceConnection.Send(new UnCacheUser(connection.Session.ID).ToPacket());

                m_ActiveConnections.Remove(connection.Session.ID);
                connection = null;
            }
        }