예제 #1
0
        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);
        }