Exemplo n.º 1
0
        public void JoinChatAndListen()
        {
            this.Focus();
            this.ConnectToChat.IsEnabled = false;
            this.ConnectToChat.Opacity = 0;

            chatJoined = true;
            try
            {
                ChatList.Add(new ChatLine { Message = "Connecting to chat...", UserName = "", Color = "#ffffff" });
                this.ChatBox.ItemsSource = this.ChatList;

                IRCConfig config;
                if (isLoggedIn)
                {
                    config = new IRCConfig
                    {
                        channel = App.ViewModel.stream.channel.name,
                        nick = App.ViewModel.user.Name,
                        pass = "******" + App.ViewModel.user.Oauth,
                        server = "irc.twitch.tv",
                        port = 6667
                    };
                }
                else
                {
                    config = new IRCConfig
                    {
                        channel = App.ViewModel.stream.channel.name,
                        nick = "justinfan"+random.Next(0,999999)+random.Next(0,99999999),
                        pass = "******",
                        server = "irc.twitch.tv",
                        port = 6667
                    };
                }

                client = new ChatClient(config);
                client.sendData("JOIN", "#" + config.channel);

                backgroundWorker.RunWorkerAsync();
            }

            catch
            {
                MessageBox.Show("Connecting to chat has run into issues", "Well, this is embarrassing...", MessageBoxButton.OK);
            }
        }
Exemplo n.º 2
0
        protected override void OnNavigatedFrom(NavigationEventArgs e)
        {
            if (chatJoined)
                rejoinChat = true;

            CleanupMedia();
            client = null;

            base.OnNavigatedFrom(e);
        }