コード例 #1
0
        private static void APIConnection_OutputData(object sender, OutputEventArgs e)
        {
            if (e.Data == null)
            {
                return;
            }

            if (e.Data.IndexOf(chatTag) == 0)
            {
                ChatData?.Invoke(sender, new OutputEventArgs(e.Data.Substring(chatTag.Length)));
            }
            else if (e.Data.IndexOf(srvDataTagPlayer) == 0)
            {
                String             result = e.Data.Substring(srvDataTagPlayer.Length);
                PlayerActivityEnum act    = PlayerActivityEnum.Join;

                if (Regex.Match(result, "[A-Za-z0-9\\-]+" + srvPlayerJoin).Success)
                {
                    act    = PlayerActivityEnum.Join;
                    result = result.Remove(result.Length - srvPlayerJoin.Length, srvPlayerJoin.Length);
                }
                if (Regex.Match(result, "[A-Za-z0-9\\-]+" + srvPlayerLeave).Success)
                {
                    act    = PlayerActivityEnum.Leave;
                    result = result.Remove(result.Length - srvPlayerLeave.Length, srvPlayerLeave.Length);
                }

                PlayerData?.Invoke(sender, new PlayerEventArgs(result, act));
            }


            ConsoleData?.Invoke(sender, e);
        }
コード例 #2
0
        public static PlaybackState FromJson(JObject json)
        {
            if (json == null)
            {
                return(null);
            }

            PlayerActivityEnum playerActivity = PlayerActivityEnum.NONE;

            Enum.TryParse(json.Value <string>("playerActivity"), out playerActivity);
            return(new PlaybackState {
                Token = json.Value <string>("token"),
                OffsetInMilliseconds = json.Value <long?>("offsetInMilliseconds"),
                PlayerActivity = playerActivity
            });
        }
コード例 #3
0
 public PlayerEventArgs(String name, PlayerActivityEnum activity) : base()
 {
     Name     = name;
     Activity = activity;
 }