public bool SetWorld(string worldId) { string savedWorldId = loginSettings.worldId; if (!networkHelper.HasWorldEntry(loginSettings.worldId)) { NetworkHelperStatus status = networkHelper.ResolveWorld(loginSettings); if (status != NetworkHelperStatus.WorldResolveSuccess) { // revert the loginSettings loginSettings.worldId = savedWorldId; return(false); } } WorldServerEntry entry = networkHelper.GetWorldEntry(worldId); parentForm.AbortUpdate(); parentForm.Updater.FullScan = false; parentForm.Updater.BaseDirectory = entry.WorldRepository; parentForm.Updater.UpdateUrl = entry.UpdateUrl; parentForm.Updater.SetupLog(logFile); 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); }
public void ReadLoopbackWorldResponse(XmlNode node) { // WorldResponse response; WorldServerEntry entry; string world_id = null; string update_url = null; string patcher_url = null; string hostname = null; int port = 0; if (node.Attributes["world_id"] == null) { Trace.TraceWarning("loopback_world_response element missing multiverse_id attribute"); } else { world_id = node.Attributes["world_id"].Value; } foreach (XmlNode child in node.ChildNodes) { switch (child.Name) { case "account": // Set our user id to be derived from our pid, so they // don't collide when we run multiple test clients Process process = Process.GetCurrentProcess(); client.LoopbackIdToken = BitConverter.GetBytes(IPAddress.HostToNetworkOrder(process.Id)); Logger.Log(2, "Setting client.LoopbackIdToken to {0}", process.Id); // if (child.Attributes["id_token"] != null) { // string token = child.Attributes["id_token"].Value; // client.LoopbackIdToken = Convert.FromBase64String(token); // } else if (child.Attributes["id_number"] != null) { // string number = child.Attributes["id_number"].Value; // int id = int.Parse(number); // client.LoopbackIdToken = BitConverter.GetBytes(IPAddress.HostToNetworkOrder(id)); // } else { // Trace.TraceWarning("account element missing multiverse_id attribute"); // } break; case "update_url": if (child.Attributes["href"] != null) { update_url = child.Attributes["href"].Value; } else { Trace.TraceWarning("update_url element missing href attribute"); } break; case "patcher_url": if (child.Attributes["href"] != null) { patcher_url = child.Attributes["href"].Value; } else { Trace.TraceWarning("patcher_url element missing href attribute"); } break; case "server": if (child.Attributes["hostname"] != null) { hostname = child.Attributes["hostname"].Value; } else { Trace.TraceWarning("server element missing hostname attribute"); } if (child.Attributes["port"] != null) { if (!int.TryParse(child.Attributes["port"].Value, out port)) { Trace.TraceWarning("server element has invalid port attribute"); } } else { Trace.TraceWarning("server element missing port attribute"); } break; } } entry = new WorldServerEntry(world_id, hostname, port, patcher_url, update_url); client.LoopbackWorldServerEntry = entry; }
public void ReadLoopbackWorldResponse(XmlNode node) { // WorldResponse response; WorldServerEntry entry; string world_id = null; string update_url = null; string patcher_url = null; string hostname = null; int port = 0; if (node.Attributes["world_id"] == null) Trace.TraceWarning("loopback_world_response element missing multiverse_id attribute"); else world_id = node.Attributes["world_id"].Value; foreach (XmlNode child in node.ChildNodes) { switch (child.Name) { case "account": // Set our user id to be derived from our pid, so they // don't collide when we run multiple test clients Process process = Process.GetCurrentProcess(); client.LoopbackIdToken = BitConverter.GetBytes(IPAddress.HostToNetworkOrder(process.Id)); Logger.Log(2, "Setting client.LoopbackIdToken to {0}", process.Id); // if (child.Attributes["id_token"] != null) { // string token = child.Attributes["id_token"].Value; // client.LoopbackIdToken = Convert.FromBase64String(token); // } else if (child.Attributes["id_number"] != null) { // string number = child.Attributes["id_number"].Value; // int id = int.Parse(number); // client.LoopbackIdToken = BitConverter.GetBytes(IPAddress.HostToNetworkOrder(id)); // } else { // Trace.TraceWarning("account element missing multiverse_id attribute"); // } break; case "update_url": if (child.Attributes["href"] != null) update_url = child.Attributes["href"].Value; else Trace.TraceWarning("update_url element missing href attribute"); break; case "patcher_url": if (child.Attributes["href"] != null) patcher_url = child.Attributes["href"].Value; else Trace.TraceWarning("patcher_url element missing href attribute"); break; case "server": if (child.Attributes["hostname"] != null) hostname = child.Attributes["hostname"].Value; else Trace.TraceWarning("server element missing hostname attribute"); if (child.Attributes["port"] != null) { if (!int.TryParse(child.Attributes["port"].Value, out port)) Trace.TraceWarning("server element has invalid port attribute"); } else Trace.TraceWarning("server element missing port attribute"); break; } } entry = new WorldServerEntry(world_id, hostname, port, patcher_url, update_url); client.LoopbackWorldServerEntry = entry; }