예제 #1
0
        /// <summary>
        /// TODO: Documentation jingleManager_OnReceivedSessionInitiate
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="iq"></param>
        private void jingleManager_OnReceivedSessionInitiate(object sender, IQ iq)
        {
            if (this.StartingSessionRecipient == null)
            {
                this.StartingSessionRecipient = iq.From;

                Jingle jingle = iq.Query as Jingle;

                this.StartingSessionSid    = jingle.Sid;
                this.StartingSessionAction = ActionType.session_accept;

                if (this.OnBeforeResponderAllocate != null)
                {
                    this.OnBeforeResponderAllocate(this, jingle.Sid);
                }

                if (this.TurnSupported)
                {
                    this.CreateTurnSession(this.StartingSessionSid, false);
                }
                else
                {
                    throw new NotSupportedException();
                }

                iq.Handled = true;
            }
        }
예제 #2
0
 public static XElement GetConfigXml(bool isExit = false)
 {
     return(new XElement(Program.ConfigName,
                         new XElement("MinimizeAtUserStartup", MinimizeAtUserStartup),
                         new XElement("MinimizeAtAutoStartup", MinimizeAtAutoStartup),
                         new XElement("NotifyWhenVRConnectionLost", NotifyWhenVRConnectionLost),
                         new XElement("ConnLostNotificationIsSticky", ConnLostNotificationIsSticky),
                         new XElement("NotifyOnAPIQuit", NotifyOnAPIQuit),
                         new XElement("TrayMenuNotifications", TrayMenuNotifications),
                         new XElement("PlaySoundOnHMDinteractionStart", PlaySoundOnHMDinteractionStart),
                         new XElement("ShowResetMessageBox", ShowResetMessageBox),
                         new XElement("LastSessionProfileName", ActiveProfile?.Name),
                         new XElement("LastExitSeconds", (isExit) ? GetCurrentSeconds() : 0),
                         new XElement("LastHalfTurn", FormMain.Tracker.CurrentHalfTurn.ToString(System.Globalization.CultureInfo.InvariantCulture)),
                         new XElement("LastYawValue", FormMain.Tracker.YawValue.ToString(System.Globalization.CultureInfo.InvariantCulture)),
                         new XElement("TurnCountMemoryMinutes", TurnCountMemoryMinutes.ToString(System.Globalization.CultureInfo.InvariantCulture)),
                         new XElement("Alarm", Alarm.GetXml()),
                         new XElement("Jingle", Jingle.GetXml()),
                         new XElement("CONSTANTS",
                                      new XComment("Wait time when starting with Windows. The purpose is to ensure that all audio devices have been initialized before using them."),
                                      new XElement("WindowsStartupWaitInSeconds", Program.WindowsStartupWaitInSeconds),
                                      new XComment("DO NOT TOUCH. These are for future proofing. In case SteamVR or Oculus Home processes are named differently in an update (unlikely)."),
                                      new XElement("OculusHomeProcessName", OculusHomeProcessName),
                                      new XElement("SteamVRProcessName", SteamVRProcessName))
                         ));
 }
예제 #3
0
        public static void CheckDefaultSounds()
        {
            if (Alarm.Wave == null)
            {
                // default alarm:
                Alarm.SetWave(new WaveFileInfo(WaveFilePool.DefaultAudioFolder_Rel + "\\CG_TickTock" + WaveFilePool.CgAudioExtension));
                Alarm.Pan       = 0;
                Alarm.Volume    = 100;
                Alarm.LoopCount = 3;
            }

            if (Jingle.Wave == null)
            {
                // default jingle:
                Jingle.SetWave(new WaveFileInfo(WaveFilePool.DefaultAudioFolder_Rel + "\\CG_Jingle" + WaveFilePool.CgAudioExtension));
                Jingle.Pan       = 0;
                Jingle.Volume    = 50;
                Jingle.LoopCount = 1;
            }

            // Connection lost sound:
            ConnLost.SetWave(new WaveFileInfo(WaveFilePool.DefaultAudioFolder_Rel + "\\CG_ConnLost" + WaveFilePool.CgAudioExtension));
            ConnLost.Pan       = 0;
            ConnLost.Volume    = 70;
            ConnLost.LoopCount = 1;
        }
예제 #4
0
        /// <summary>
        /// TODO: Documentation jingleManager_OnReceivedTransportInfo
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="iq"></param>
        private void jingleManager_OnReceivedTransportInfo(object sender, IQ iq)
        {
            Jingle jingle = iq.Query as Jingle;

            JingleContent jingleContent = jingle.GetContent(0);

            if (jingleContent.ContentName == "checkConnectivity")
            {
                this.CheckConnectivity(jingle.Sid);

                iq.Handled = true;
            }
        }
예제 #5
0
        /// <summary>
        /// TODO: Documentation jingleManager_OnReceivedSessionTerminate
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="iq"></param>
        private void jingleManager_OnReceivedSessionTerminate(object sender, IQ iq)
        {
            Jingle jingle = iq.Query as Jingle;

            if (jingle != null)
            {
                if (this.TurnSupported)
                {
                    this.DestroyTurnSession(jingle.Sid);
                }
                else
                {
                    throw new NotSupportedException();
                }

                this.CancelStartingSession(jingle.Sid);
            }
        }
예제 #6
0
        /// <summary>
        /// TODO: Documentation jingleManager_OnReceivedSessionAccept
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="iq"></param>
        private void jingleManager_OnReceivedSessionAccept(object sender, IQ iq)
        {
            Jingle jingle = iq.Query as Jingle;

            JingleIQ jingleIq = new JingleIQ(this.Stream.Document);

            jingleIq.From = this.Stream.JID;
            jingleIq.To   = iq.From;
            jingleIq.Type = IQType.set;
            jingleIq.Instruction.Action = ActionType.transport_info;
            jingleIq.Instruction.Sid    = jingle.Sid;

            JingleContent jcnt = jingleIq.Instruction.AddContent("checkConnectivity");

            this.Stream.Write(jingleIq);
            this.CheckConnectivity(jingle.Sid);

            iq.Handled = true;
        }
예제 #7
0
        public void Play(out Team Winner)
        {
            Start?.Invoke();
            Jingle?.Invoke("/Opening.mp3");
            RequestIn("Готовы к следующему раунду?");

            foreach (Round round in Rounds)
            {
                CurrentRound = round;
                RequestOut($"== {round.Name} ==");
                Jingle?.Invoke(round.Jingle);
                RefreshBoard?.Invoke();

                int score = round.Play(out Winner);
                Winner.Score += score;
                SetScore();

                RequestOut("-- Открываем табло --");
                round.Reveal();
                RequestIn("Готовы к следующему раунду?");
            }

            CurrentRound = FinalRound;
            RequestOut($"== {FinalRound.Name} ==");
            Jingle?.Invoke(FinalRound.Jingle);
            ShowTitle();
            FinalRound.Play(out Winner);

            Winner = Teams.OrderByDescending(team => team.Score)
                     .Take(1)
                     .Single();

            Jingle?.Invoke("/Closing.mp3");
            RequestIn("Нажмите для завершения игры");
            ShowTitle();
            TheEnd?.Invoke();
        }
예제 #8
0
        /// <summary>
        /// Analyses an IQ paquet and chooses to handle it or not
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="iq"></param>
        private void GotIQ(object sender, IQ iq)
        {
            Jingle jingle = iq.Query as Jingle;

            if (jingle != null)
            {
                if (jingle.Action == ActionType.session_terminate)
                {
                    this.Stream.Write(iq.GetAcknowledge(this.Stream.Document));

                    if (this.OnReceivedSessionTerminate != null)
                    {
                        this.OnReceivedSessionTerminate(this, iq);
                    }

                    if (this.Sessions.ContainsKey(jingle.Sid))
                    {
                        this.Sessions.Remove(jingle.Sid);
                    }

                    iq.Handled = true;
                }
                else
                {
                    if (!this.AllowSessionInitiateFrom(iq.From))
                    {
                        this.SessionTerminate(iq.From, jingle.Sid, ReasonType.security_error);
                        iq.Handled = true;
                    }
                    else
                    {
                        switch (jingle.Action)
                        {
                        case ActionType.session_initiate:
                            this.Stream.Write(iq.GetAcknowledge(this.Stream.Document));

                            if (!this.Sessions.ContainsKey(jingle.Sid))
                            {
                                JingleSession jingleSession = new JingleSession();
                                jingleSession.SID    = jingle.Sid;
                                jingleSession.Remote = jingle;

                                this.Sessions.Add(jingle.Sid, jingleSession);
                            }

                            if (this.OnReceivedSessionInitiate != null)
                            {
                                this.OnReceivedSessionInitiate(this, iq);
                            }

                            if (!iq.Handled)
                            {
                                this.SessionTerminate(iq.From, jingle.Sid, ReasonType.decline);
                                iq.Handled = true;
                            }

                            break;

                        case ActionType.session_accept:
                            this.Stream.Write(iq.GetAcknowledge(this.Stream.Document));

                            if (!this.Sessions.ContainsKey(jingle.Sid))
                            {
                                JingleSession jingleSession = new JingleSession();
                                jingleSession.SID    = jingle.Sid;
                                jingleSession.Remote = jingle;

                                this.Sessions.Add(jingle.Sid, jingleSession);
                            }

                            if (this.OnReceivedSessionAccept != null)
                            {
                                this.OnReceivedSessionAccept(this, iq);
                            }

                            if (!iq.Handled)
                            {
                                this.SessionTerminate(iq.From, jingle.Sid, ReasonType.cancel);
                                iq.Handled = true;
                            }

                            break;

                        case ActionType.session_info:
                            if (this.Sessions.ContainsKey(jingle.Sid))
                            {
                                this.Stream.Write(iq.GetAcknowledge(this.Stream.Document));
                            }
                            else
                            {
                                this.Stream.Write(new UnknownSession(this.Stream.Document));
                            }

                            if (this.OnReceivedSessionInfo != null)
                            {
                                this.OnReceivedSessionInfo(this, iq);
                            }

                            break;

                        case ActionType.transport_info:
                            if (this.Sessions.ContainsKey(jingle.Sid))
                            {
                                this.Stream.Write(iq.GetAcknowledge(this.Stream.Document));
                            }
                            else
                            {
                                this.Stream.Write(new UnknownSession(this.Stream.Document));
                            }

                            if (this.OnReceivedTransportInfo != null)
                            {
                                this.OnReceivedTransportInfo(this, iq);
                            }

                            break;
                        }
                    }
                }
            }
        }
예제 #9
0
        public static void LoadConfigFromXml(XElement xConfig)
        {
            if (xConfig != null)
            {
                if (xConfig.GetElementValueOrNull("API") != null) // backwards compatibility
                {
                    IsLegacyConfig = true;
                    if (Enum.TryParse(xConfig.GetElementValueTrimmed("API"), out VRAPI a))
                    {
                        LegacyAPI = a;
                    }
                }

                if (xConfig.GetElementValueOrNull("StartMinimized") != null) // backwards compatibility
                {
                    MinimizeAtUserStartup = xConfig.GetElementValueBool("StartMinimized");
                    MinimizeAtAutoStartup = MinimizeAtUserStartup;
                }
                else
                {
                    MinimizeAtUserStartup = xConfig.GetElementValueBool("MinimizeAtUserStartup");

                    if (xConfig.GetElementValueOrNull("MinimizeAtWindowsStartup") != null) // backwards compatibility
                    {
                        MinimizeAtAutoStartup = xConfig.GetElementValueBool("MinimizeAtWindowsStartup");
                    }
                    else
                    {
                        MinimizeAtAutoStartup = xConfig.GetElementValueBool("MinimizeAtAutoStartup");
                    }
                }

                NotifyWhenVRConnectionLost   = xConfig.GetElementValueBool("NotifyWhenVRConnectionLost", true);
                ConnLostNotificationIsSticky = xConfig.GetElementValueBool("ConnLostNotificationIsSticky", true);
                NotifyOnAPIQuit                = xConfig.GetElementValueBool("NotifyOnAPIQuit");
                TrayMenuNotifications          = xConfig.GetElementValueBool("TrayMenuNotifications", true);
                PlaySoundOnHMDinteractionStart = xConfig.GetElementValueBool("PlaySoundOnHMDinteractionStart");
                ShowResetMessageBox            = xConfig.GetElementValueBool("ShowResetMessageBox", true);
                LastSessionProfileName         = xConfig.GetElementValueTrimmed("LastSessionProfileName");
                LastExitSeconds                = xConfig.GetElementValueUInt("LastExitSeconds");
                LastHalfTurn = xConfig.GetElementValueInt("LastHalfTurn");
                LastYawValue = xConfig.GetElementValueDouble("LastYawValue");

                if (xConfig.GetElementValueOrNull("TurnCountMemoryMinutes") != null)
                {
                    TurnCountMemoryMinutes = xConfig.GetElementValueInt("TurnCountMemoryMinutes");
                }
                else
                {
                    TurnCountMemoryMinutes = -1;
                }

                XElement xAlarm = xConfig.Element("Alarm");
                Alarm.LoadFromXml(xAlarm?.Element("CGActionWaveFile"));

                XElement xJingle = xConfig.Element("Jingle");
                Jingle.LoadFromXml(xJingle?.Element("CGActionWaveFile"));

                XElement cons = xConfig.Element("CONSTANTS");
                if (cons != null)
                {
                    string temp = cons.GetElementValueTrimmed("OculusHomeProcessName");
                    if (!String.IsNullOrWhiteSpace(temp))
                    {
                        OculusHomeProcessName = temp;
                    }

                    temp = cons.GetElementValueTrimmed("SteamVRProcessName");
                    if (!String.IsNullOrWhiteSpace(temp))
                    {
                        SteamVRProcessName = temp;
                    }
                }
            }
        }