public void SimControlLoadForkReplay(String scenarioPath, String groupName, String outputLogDir, String replayLogPath, Double replaySpeed) { if (!File.Exists(scenarioPath)) { SendServerStateEvent("FORK_REPLAY_LOAD_FAILURE", "Specified scenario does not exist"); } if (replayLogPath == this.Log) { SendServerStateEvent("FORK_REPLAY_LOAD_FAILURE", "Your current replay log is set to the same file as the file you'll be replaying from. To prevent error, change one of these two files before starting the server."); return; } if (groupName.Contains("\\") || groupName.Contains("/")) { SendServerStateEvent("FORK_REPLAY_LOAD_FAILURE", "Invalid input in Group Name. Cannot contain \\ or /."); } Authenticator.LoadUserFile(); if (Authenticator.GetNumUsers() == 0) { SendServerStateEvent("FORK_REPLAY_LOAD_FAILURE", "You must create at least one user account before starting the server.\nUse the Users-->User Administration menu item."); } try { StreamReader re = File.OpenText(replayLogPath); string input = re.ReadLine(); re.Close(); creatorRegex = new Regex(@"^<Creator><Version>" + SimCoreServer.GetProductVersion() + "</Version><CompiledOn>" + SimCoreServer.GetCompileDate() + "</CompiledOn></Creator>$", RegexOptions.Singleline); if (!creatorRegex.IsMatch(input)) { SendServerStateEvent("FORK_REPLAY_LOAD_FAILURE", "This file must be replayed in a different version of the DDD."); return; } } catch (System.IO.IOException exc) { SendServerStateEvent("FORK_REPLAY_LOAD_FAILURE", String.Format("The selected file could not be opened for replay.\n{0}", exc.Message)); return; } string logType = "NOLOG"; switch (ServerOptions.EventLogType) { case "DETAILED": logType = "Detailed"; break; case "LIMITED": logType = "Limited"; break; default: break; } ServerOptions.DefaultScenarioPath = scenarioPath; ServerOptions.EventLogDirectory = outputLogDir; LoadScenario(logType, DateTime.Now, groupName, replayLogPath); }
public void SimControlLoadReplay(String replayLogPath, Double replaySpeed) { Authenticator.LoadUserFile(); if (replayLogPath == this.Log) { SendServerStateEvent("REPLAY_LOAD_FAILURE", "Your current replay log is set to the same file as the file you'll be replaying from. To prevent error, change one of these two files before starting the server."); return; } if (Authenticator.GetNumUsers() == 0) { SendServerStateEvent("REPLAY_LOAD_FAILURE", "You must create at least one user account before loading a replay.\nUse the Users-->User Administration menu item."); return; } try { StreamReader re = File.OpenText(replayLogPath); string input = re.ReadLine(); re.Close(); creatorRegex = new Regex(@"^<Creator><Version>" + SimCoreServer.GetProductVersion() + "</Version><CompiledOn>" + SimCoreServer.GetCompileDate() + "</CompiledOn></Creator>$", RegexOptions.Singleline); if (!creatorRegex.IsMatch(input)) { SendServerStateEvent("REPLAY_LOAD_FAILURE", "This file must be replayed in a different version of the DDD."); return; } } catch (System.IO.IOException exc) { SendServerStateEvent("REPLAY_LOAD_FAILURE", String.Format("The selected file could not be opened for replay.\n{0}", exc.Message)); return; } simEngine.StartTextChatServer(); simEngine.StartWhiteboardServer(); // Start the voice server if it exists and is needed // The conditions will be added later if (ServerOptions.EnableVoiceServer) { // Get the simulation start time from the replay filename DateTime time = DateTime.Now; try { string timeString = replayLogPath.Remove(replayLogPath.LastIndexOf('.')); timeString = timeString.Substring(timeString.LastIndexOf('.') + 1); time = DateTime.ParseExact(timeString, "yyyyMMddHHmmss", null); } catch (Exception exc) { } HandshakeManager.SetVoiceEnabled(true); HandshakeManager.SetVoiceServerName(ServerOptions.VoiceServerHostname); HandshakeManager.SetVoiceServerPassword(ServerOptions.VoiceServerUserPassword); HandshakeManager.SetVoiceServerPort(ServerOptions.VoiceServerPort); simEngine.StartVoiceServer(ServerOptions.VoiceServerPort, ServerOptions.VoiceServerUserPassword, ServerOptions.VoiceServerAdminUsername, ServerOptions.VoiceServerAdminPassword, ServerOptions.EnableVoiceServerRecordings, time, true, replaySpeed); } else { HandshakeManager.SetVoiceEnabled(false); HandshakeManager.SetVoiceServerName(ServerOptions.VoiceServerHostname); HandshakeManager.SetVoiceServerPassword(ServerOptions.VoiceServerUserPassword); HandshakeManager.SetVoiceServerPort(ServerOptions.VoiceServerPort); } this.StartReplay(replayLogPath, false); this.SimControlPauseScenario(); SimCoreServer.replayState = Aptima.Asim.DDD.SimCoreServer.SimCoreServer.ScenarioState.LOADING; this.SetReplaySpeed(replaySpeed); }