コード例 #1
0
 public void SetupPipes(PipeStatus s = PipeStatus.NORMAL)
 {
     for (var i = 1; i <= 5; i++)
     {
         Thread.Sleep(1);
         SetPipe((PipeIdent)i, s);
     }
 }
コード例 #2
0
ファイル: FloatingTag.cs プロジェクト: ztl19930409/AR
 // Update is called once per frame
 void UpdateStatus(PipeStatus status)
 {
     if (status == PipeStatus.Normal)
     {
     }
     else if (status == PipeStatus.Abnormal)
     {
     }
     Status.text = status.ToString();
 }
コード例 #3
0
        public void SetPipe(PipeIdent id, PipeStatus status)
        {
            string master = _client.GetOpcodeCmd(Opcodes.ServerOpcodes.SMSG_WRAPPER_SET_PIPE);
            JToken cmd    = JToken.FromObject(new SetPipeColorCommand()
            {
                PipeId     = id,
                PipeStatus = status
            });

            _client.SendMsg(_client.AddPayload(master, cmd));
        }
コード例 #4
0
 public void Start()
 {
     Trace.Assert(Status == PipeStatus.NotStarted);
     Status = PipeStatus.Running;
     try { Run(); writer.Close(); }
     catch (Exception error) { Exception = error; }
     finally
     {
         reader.Dispose();
         writer.Dispose();
         Status = PipeStatus.Finished;
     }
 }
コード例 #5
0
        //public void InitPipes()
        //{
        //    string master = _client.GetOpcodeCmd(Opcodes.ServerOpcodes.SMSG_WRAPPER_INIT_PIPES);
        //    List<SetPipeColorCommand> spcc = new List<SetPipeColorCommand>
        //    {
        //        new SetPipeColorCommand() {PipeStartPoint = 1, PipeEndPoint = 3, PipeStatus = PipeStatus.NORMAL},
        //        new SetPipeColorCommand() {PipeStartPoint = 3, PipeEndPoint = 4, PipeStatus = PipeStatus.NORMAL},
        //        new SetPipeColorCommand() {PipeStartPoint = 4, PipeEndPoint = 2, PipeStatus = PipeStatus.NORMAL}
        //    };
        //    JToken cmd = JToken.FromObject(new InitPipesCommand()
        //    {
        //        Phase = _client.SessionPointer.ActivePhase,
        //        Pipes = spcc
        //    });
        //    _client.SendMsg(_client.AddPayload(master, cmd));
        //}

        public void UpdatePipes(Client c)
        {
            GameResponse gr     = c.SessionPointer.GameUpdateResponse[c.ClientIdent];
            PipeStatus   status = PipeStatus.NORMAL;

            if (gr.CommulativeScore <= 100)
            {
                status = PipeStatus.NORMAL;
            }
            if ((double)gr.CommulativeScore < 2.0 * 100.0 / 3.0)
            {
                status = PipeStatus.WARNING;
            }
            if ((double)gr.CommulativeScore < 1.0 * 100.0 / 3.0)
            {
                status = PipeStatus.CRITICAL;
            }
            SetPipe((PipeIdent)(c.WindowId + 1), status);
        }
コード例 #6
0
ファイル: Pipe.cs プロジェクト: nwtgck/PipingServer.NET
        private async ValueTask <bool> SetStatusAsync(PipeStatus value, CancellationToken Token = default)
        {
            if (((byte)Status) >= (byte)value)
            {
                return(false);
            }
            await Semaphore.WaitAsync(Token).ConfigureAwait(false);

            try
            {
                Status = value;
                OnStatusChanged?.Invoke(this, new PipeStatusChangedArgs(this, Headers));
            }
            finally
            {
                try
                {
                    Semaphore.Release();
                }
                catch (ObjectDisposedException) { }
            }
            return(true);
        }
コード例 #7
0
        public void HandleMessage(string message)
        {
            Logging.LogMsg(Logging.LogLevel.DEBUG, "ControlClient: " + message);
            SessionHandler handler = _client.SessionPointer.HandlerInstance;

            try
            {
                string[] cmd = message.Split(Convert.ToChar(";"));
                int      phase;
                switch (cmd[0])
                {
                case "startintro":
                    phase = int.Parse(cmd[1]);
                    handler.SessionEvents.StartIntro(phase);
                    break;

                case "loadgames":
                    phase = int.Parse(cmd[1]);
                    handler.SessionEvents.LoadGames(phase);
                    break;

                case "initpipes":
                    phase = int.Parse(cmd[1]);
                    //handler.SessionEvents.InitPipes(phase);
                    handler.ActiveSession.GetClient(Client.ClientType.Wrapper)?.WE?.SetupPipes();
                    break;

                case "setpipe":
                    var        id     = int.Parse(cmd[1]);
                    PipeStatus status = (PipeStatus)int.Parse(cmd[2]);
                    handler.ActiveSession.GetClient(Client.ClientType.Wrapper)?.WE.SetPipe((PipeIdent)id, status);
                    break;

                case "getfeedback":
                    phase = int.Parse(cmd[1]);
                    handler.SessionEvents.ShowGameFeedback(phase, true);
                    break;

                case "getteamfeedback":
                    handler.SessionEvents.ShowTeamFeedback(true);
                    break;

                case "switchphase":
                    if (handler == null)
                    {
                        return;
                    }
                    if (handler.SessionActive)
                    {
                        _client.SendMsg("Invalid action: Stop active Phase first!");
                        return;
                    }
                    handler.SetPhase(int.Parse(cmd[1]));
                    break;

                case "initsession":
                    if (handler == null)
                    {
                        return;
                    }
                    if (handler.SessionActive)
                    {
                        _client.SendMsg("Invalid action: Stop Phase first!");
                        return;
                    }
                    if (cmd.Length >= 3 && !string.IsNullOrEmpty(cmd[2]))
                    {
                        handler.ActiveSession.SessionConfig.Timelimit = int.Parse(cmd[2]);
                    }
                    var gc = handler.ActiveSession.GetInitializedGameClients();
                    if (gc == null)
                    {
                        return;
                    }
                    foreach (var g in gc)
                    {
                        g.GE.InitGame();
                    }

                    break;

                case "startsession":
                    if (handler == null)
                    {
                        return;
                    }
                    if (handler.SessionActive)
                    {
                        _client.SendMsg("Invalid action: Stop Phase first!");
                        return;
                    }
                    phase = int.Parse(cmd[1]);
                    handler.SessionEvents.StartGameSession(phase);
                    break;

                case "pausesession":
                    if (handler == null)
                    {
                        return;
                    }
                    handler.SessionEvents.PauseSession();
                    break;

                case "continuesession":
                    if (handler == null)
                    {
                        return;
                    }
                    handler.SessionEvents.ContinueSession();
                    break;

                case "endsession":
                    if (handler == null)
                    {
                        return;
                    }
                    handler.SessionEvents.ForceEndGameSession();
                    break;

                case "breakclient":
                    if (handler == null)
                    {
                        return;
                    }
                    if (cmd.Length < 2 || string.IsNullOrEmpty(cmd[1]))
                    {
                        _client.SendMsg("Invalid action: Specify ClientId!");
                        return;
                    }
                    Client.ClientType clientid = (Client.ClientType) int.Parse(cmd[1]);
                    handler.ActiveSession.GetClient(clientid)?.GE.InterruptGame();
                    break;

                case "start":
                    if (handler == null)
                    {
                        return;
                    }
                    handler.SessionEvents.StartGameSession();
                    break;

                case "end":
                    if (handler == null)
                    {
                        return;
                    }
                    handler.SessionEvents.ForceEndGameSession();
                    break;

                case "setsheet":
                    if (handler == null)
                    {
                        return;
                    }
                    handler.SessionEvents.ChangeSpecificSheet(Convert.ToInt32(cmd[1]));
                    break;

                default:
                    break;
                }
            }
            catch (Exception)
            {
                throw;
            }
        }