static void Main(string[] args)
    {
        g_serverConfig = new F3.Network.F3_ServerConfig();

        if (args.Length > 1)
        {
            //use custom config
            if (args[0] == "-c" && args.Length == 2)
            {
                g_serverConfig.LoadFromXML(args[1]);
            }
        }

        DateTime m_registerTimer = DateTime.Now;
        DateTime m_refreshToken = DateTime.Now;

        network.StartServer(g_serverConfig);

        while (network.IsServerRunning())
        {
            TimeSpan registerDiff = DateTime.Now - m_registerTimer;
            TimeSpan tokenDiff = DateTime.Now - m_refreshToken;

            if (registerDiff.TotalMilliseconds >= 30000)
            {
                m_registerTimer = DateTime.Now;
                OnRegister();
            }

            if (tokenDiff.TotalMilliseconds >= 300000)
            {
                m_refreshToken = DateTime.Now;
                OnRefreshToken();
            }
        }
    }
        public virtual void StartServer(F3_ServerConfig serverConfig)
        {
            m_connectedPlayers = new Dictionary<long, F3_NetPlayerInfo>();

            NetPeerConfiguration config = new NetPeerConfiguration(serverConfig.GetAppID());
            config.EnableMessageType(NetIncomingMessageType.ConnectionApproval);
            config.EnableMessageType(NetIncomingMessageType.NatIntroductionSuccess);
            config.EnableMessageType(NetIncomingMessageType.UnconnectedData);
            config.EnableMessageType(NetIncomingMessageType.StatusChanged);
            config.LocalAddress = serverConfig.GetIpAdress();
            config.Port = serverConfig.GetPort();

            m_server = new NetServer(config);
            m_server.Start();

            m_listener = new F3_ServerListenerThread(serverConfig.GetAppID(), this);

            m_bNeedRegistration = serverConfig.HasToRegister();
            m_serverType = serverConfig.GetServerType();
            m_maxPlayers = serverConfig.GetMaxPlayers();

            if (m_bNeedRegistration)
            {
                RegisterToMasterServer(true);
            }
        }
        public override void StartServer(F3_ServerConfig serverConfig)
        {
            m_messages = new NetQueue<F3_ChatLine>(16);
            m_commands = new NetQueue<NetCommand>(16);
            m_registeredGroups = new Dictionary<string, List<long>>();

            base.StartServer(serverConfig);
        }
        public override void StartServer(F3_ServerConfig serverConfig)
        {
            m_consoleOuputMsg = new NetQueue<string>(16);
            m_registeredServers = new Dictionary<long, F3_NetServerInfo>();

            base.StartServer(serverConfig);
        }
 public override void StartServer(F3_ServerConfig serverConfig)
 {         
     ConnectToDatabase();
     base.StartServer(serverConfig);
     m_bIsRunning = true;
 }