/// <summary>
        ///		Overridden to switch to event based keyboard input.
        /// </summary>
        /// <returns></returns>
        protected bool Setup()
        {
#if USE_PERFORMANCE_COUNTERS
            SetupPerformanceCategories();
            CreateCounters();
#endif
            this.Tick += new TickEvent(OnTick);

            worldManager = new WorldManager(verifyServer, behaviorParms);
            NetworkHelper helper = new NetworkHelper(worldManager);
            if (this.LoopbackWorldServerEntry != null)
            {
                string worldId = this.LoopbackWorldServerEntry.WorldName;
                // Bypass the login and connection to master server
                loginSettings.worldId = worldId;
                helper.SetWorldEntry(worldId, this.LoopbackWorldServerEntry);
                helper.AuthToken = this.LoopbackIdToken;
            }
            networkHelper = helper;

            // Sets up the various things attached to the world manager,
            // as well as registering the various message handlers.
            // This also initializes the networkHelper.
            worldManager.Init(this);

            // Register our handlers.  We must do this before we call
            // MessageDispatcher.Instance.HandleMessageQueue, so that we will
            // get the callbacks for the incoming messages.


#if NOT
            // NOTE: Test client isn't advanced enough to handle these.

            // Register our handler for the Portal messages, so that we
            // can drop our connection to the world server, and establish a new
            // connection to the new world.
            MessageDispatcher.Instance.RegisterHandler(WorldMessageType.Portal,
                                                       new MessageHandler(this.HandlePortal));
            // Register our handler for the UiTheme messages, so that we
            // can swap out the user interface.
            MessageDispatcher.Instance.RegisterHandler(WorldMessageType.UiTheme,
                                                       new MessageHandler(this.HandleUiTheme));
#endif
            // Register our handler for the LoginResponse messages, so that we
            // can throw up a dialog if needed.
            MessageDispatcher.Instance.RegisterHandler(WorldMessageType.LoginResponse,
                                                       new WorldMessageHandler(this.HandleLoginResponse));

            if (!networkHelper.HasWorldEntry(loginSettings.worldId))
            {
                networkHelper.ResolveWorld(loginSettings);
            }
            WorldServerEntry    entry  = networkHelper.GetWorldEntry(loginSettings.worldId);
            NetworkHelperStatus status = networkHelper.ConnectToLogin(loginSettings.worldId);

            // We need to hook our message filter, whether or not we are
            // standalone, so instead of doing it later (right before
            // RdpWorldConnect), do it here.
            RequireLoginFilter checkAndHandleLogin = new RequireLoginFilter(worldManager);
            MessageDispatcher.Instance.SetWorldMessageFilter(checkAndHandleLogin.ShouldQueue);

            if (status != NetworkHelperStatus.Success &&
                status != NetworkHelperStatus.Standalone)
            {
                Trace.TraceInformation("World Connect Status: " + status);
                return(false);
            }

            networkHelper.DisconnectFromLogin();
            CharacterEntry charEntry = SelectCharacter(networkHelper.CharacterEntries, -1);
            status = networkHelper.ConnectToWorld(charEntry.CharacterId,
                                                  charEntry.Hostname,
                                                  charEntry.Port, this.Version);
            if (status != NetworkHelperStatus.Success)
            {
                Trace.TraceInformation("World Connect Status: " + status);
                return(false);
            }

            // At this point, the network helper can start handling messages.
            if (!WaitForStartupMessages())
            {
                if (loginFailed && loginMessage != null)
                {
                    // The server rejected our login
                    throw new ClientException(loginMessage);
                }
                else if (loginMessage != null)
                {
                    // our login went ok (and we got something back), but something else (terrain/player) failed
                    throw new ClientException("Unable to communicate with server");
                }
                else
                {
                    throw new ClientException("Unable to connect to server");
                }
            }

            // At this point, I can have a camera

            // networkHelper.WorldManager = worldManager;

            // inputHandler.InitViewpoint(worldManager.Player);

            Logger.Log(4, "Client setup complete: " + DateTime.Now);
            // At this point, you can create timer events.
            return(true);
        }
		/// <summary>
        ///		Overridden to switch to event based keyboard input.
        /// </summary>
        /// <returns></returns>
        protected bool Setup() {

#if USE_PERFORMANCE_COUNTERS
			SetupPerformanceCategories();
			CreateCounters();
#endif
            this.Tick += new TickEvent(OnTick);

			worldManager = new WorldManager(verifyServer, behaviorParms);
			NetworkHelper helper = new NetworkHelper(worldManager);
			if (this.LoopbackWorldServerEntry != null) {
				string worldId = this.LoopbackWorldServerEntry.WorldName;
				// Bypass the login and connection to master server
				loginSettings.worldId = worldId;
				helper.SetWorldEntry(worldId, this.LoopbackWorldServerEntry);
				helper.AuthToken = this.LoopbackIdToken;
			}
			networkHelper = helper;

            // Sets up the various things attached to the world manager, 
			// as well as registering the various message handlers.
			// This also initializes the networkHelper.
			worldManager.Init(this);

            // Register our handlers.  We must do this before we call
            // MessageDispatcher.Instance.HandleMessageQueue, so that we will
            // get the callbacks for the incoming messages.

            
#if NOT
            // NOTE: Test client isn't advanced enough to handle these.

            // Register our handler for the Portal messages, so that we
            // can drop our connection to the world server, and establish a new 
            // connection to the new world.
            MessageDispatcher.Instance.RegisterHandler(WorldMessageType.Portal,
                                                       new MessageHandler(this.HandlePortal));
            // Register our handler for the UiTheme messages, so that we
            // can swap out the user interface.
            MessageDispatcher.Instance.RegisterHandler(WorldMessageType.UiTheme,
                                                       new MessageHandler(this.HandleUiTheme));
#endif
            // Register our handler for the LoginResponse messages, so that we
            // can throw up a dialog if needed.
            MessageDispatcher.Instance.RegisterHandler(WorldMessageType.LoginResponse,
                                                       new WorldMessageHandler(this.HandleLoginResponse));

            if (!networkHelper.HasWorldEntry(loginSettings.worldId))
                networkHelper.ResolveWorld(loginSettings);
            WorldServerEntry entry = networkHelper.GetWorldEntry(loginSettings.worldId);
            NetworkHelperStatus status = networkHelper.ConnectToLogin(loginSettings.worldId);

            // We need to hook our message filter, whether or not we are 
            // standalone, so instead of doing it later (right before 
            // RdpWorldConnect), do it here.
            RequireLoginFilter checkAndHandleLogin = new RequireLoginFilter(worldManager);
            MessageDispatcher.Instance.SetWorldMessageFilter(checkAndHandleLogin.ShouldQueue);

            if (status != NetworkHelperStatus.Success &&
                status != NetworkHelperStatus.Standalone) {
                Trace.TraceInformation("World Connect Status: " + status);
                return false;
            }

            networkHelper.DisconnectFromLogin();
            CharacterEntry charEntry = SelectCharacter(networkHelper.CharacterEntries, -1);
            status = networkHelper.ConnectToWorld(charEntry.CharacterId,
                                                  charEntry.Hostname,
                                                  charEntry.Port, this.Version);
            if (status != NetworkHelperStatus.Success) {
                Trace.TraceInformation("World Connect Status: " + status);
                return false;
            }

			// At this point, the network helper can start handling messages.
            if (!WaitForStartupMessages()) {
                if (loginFailed && loginMessage != null)
                    // The server rejected our login
                    throw new ClientException(loginMessage);
                else if (loginMessage != null)
                    // our login went ok (and we got something back), but something else (terrain/player) failed
                    throw new ClientException("Unable to communicate with server");
                else
                    throw new ClientException("Unable to connect to server");
            }

			// At this point, I can have a camera

            // networkHelper.WorldManager = worldManager;

			// inputHandler.InitViewpoint(worldManager.Player);

			Logger.Log(4, "Client setup complete: " + DateTime.Now);
			// At this point, you can create timer events.
			return true;
        }