Пример #1
0
 public SpeedRunsLiveForm(LiveSplitState state, ITimerModel model, string gameName, string gameID, string gameCategory)
 {
     DownloadAllEmotes();
     GameId                        = gameID;
     GameCategory                  = gameCategory;
     SRLClient                     = new SpeedRunsLiveIRC(state, model, new[] { "#speedrunslive" });
     SRLClient.GameName            = gameName;
     SRLClient.ChannelJoined      += SRLClient_ChannelJoined;
     SRLClient.RawMessageReceived += SRLClient_RawMessageReceived;
     SRLClient.MessageReceived    += SRLClient_MessageReceived;
     SRLClient.StateChanged       += SRLClient_StateChanged;
     SRLClient.UserListRefreshed  += SRLClient_UserListRefreshed;
     SRLClient.GoalChanged        += SRLClient_GoalChanged;
     SRLClient.PasswordIncorrect  += SRLClient_PasswordIncorrect;
     SRLClient.NicknameInUse      += SRLClient_NicknameInUse;
     SRLClient.Disconnected       += SRLClient_Disconnected;
     SRLClient.Kicked             += SRLClient_Kicked;
     InitializeComponent();
     SRLClient_StateChanged(null, RaceState.NotInRace);
     btnJoinQuit.Enabled = false;
     FormIsClosing       = false;
 }
Пример #2
0
 public SpeedRunsLiveForm(LiveSplitState state, ITimerModel model, string raceId)
 {
     DownloadAllEmotes();
     RaceId = raceId;
     GameCategory = null;
     var raceChannel = string.Format("#srl-{0}", raceId);
     var liveSplitChannel = string.Format("{0}-livesplit", raceChannel);
     SRLClient = new SpeedRunsLiveIRC(state, model, new[] { "#speedrunslive", raceChannel, liveSplitChannel });
     SRLClient.ChannelJoined += SRLClient_ChannelJoined;
     SRLClient.RawMessageReceived += SRLClient_RawMessageReceived;
     SRLClient.MessageReceived += SRLClient_MessageReceived;
     SRLClient.StateChanged += SRLClient_StateChanged;
     SRLClient.UserListRefreshed += SRLClient_UserListRefreshed;
     SRLClient.GoalChanged += SRLClient_GoalChanged;
     SRLClient.PasswordIncorrect += SRLClient_PasswordIncorrect;
     SRLClient.NicknameInUse += SRLClient_NicknameInUse;
     SRLClient.Disconnected += SRLClient_Disconnected;
     SRLClient.Kicked += SRLClient_Kicked;
     InitializeComponent();
     SRLClient_StateChanged(null, RaceState.NotInRace);
     btnJoinQuit.Enabled = false;
     FormIsClosing = false;
 }
        public void CheckRace()
        {
            try {
                if ((srl != null && (srl.IsDisposed || !srl.Visible)))
                {
                    Clear();
                }

                if (raceIRC == null || liveSplitChannel == null || raceClient == null)
                {
                    foreach (var form in Application.OpenForms)
                    {
                        SpeedRunsLiveForm srlForm = form as SpeedRunsLiveForm;

                        if (srlForm != null && !srlForm.IsDisposed && srlForm.Visible)
                        {
                            srl = srlForm;

                            PropertyInfo[] fields = typeof(SpeedRunsLiveForm).GetProperties(BindingFlags.Instance | BindingFlags.NonPublic);
                            PropertyInfo   field  = null;
                            for (int i = 0; i < fields.Length; i++)
                            {
                                if (fields[i].Name.IndexOf("SRLClient", StringComparison.OrdinalIgnoreCase) >= 0 && fields[i].PropertyType == typeof(SpeedRunsLiveIRC))
                                {
                                    field = fields[i];
                                    break;
                                }
                            }

                            if (field != null)
                            {
                                raceIRC = (SpeedRunsLiveIRC)field.GetValue(srl);
                            }

                            if (raceIRC != null)
                            {
                                fields = typeof(SpeedRunsLiveIRC).GetProperties(BindingFlags.Instance | BindingFlags.NonPublic);
                                field  = null;
                                for (int i = 0; i < fields.Length; i++)
                                {
                                    if (fields[i].Name.IndexOf("LiveSplitChannel", StringComparison.OrdinalIgnoreCase) >= 0 && fields[i].PropertyType == typeof(IrcChannel))
                                    {
                                        field = fields[i];
                                        break;
                                    }
                                }
                                if (field != null)
                                {
                                    liveSplitChannel = (IrcChannel)field.GetValue(raceIRC);
                                }

                                field = null;
                                for (int i = 0; i < fields.Length; i++)
                                {
                                    if (fields[i].Name.IndexOf("Client", StringComparison.OrdinalIgnoreCase) >= 0 && fields[i].PropertyType == typeof(IrcClient))
                                    {
                                        field = fields[i];
                                        break;
                                    }
                                }
                                if (field != null)
                                {
                                    raceClient = (IrcClient)field.GetValue(raceIRC);
                                }
                            }
                            break;
                        }
                    }
                }

                if (raceIRC != null && liveSplitChannel != null && raceClient != null)
                {
                    UserName = raceIRC.Username;
                    if (!hooked)
                    {
                        liveSplitChannel.MessageReceived += LiveSplitChannel_MessageReceived;
                        raceClient.LocalUser.MessageSent += LiveSplitChannel_MessageReceived;
                    }
                    hooked = true;
                }
            } catch { }
        }