Esempio n. 1
0
        static void Main(string[] args)
        {
            using (var gg = new GG()) {
                gg.OnGetUsersList += (sender, users) => {
                    Console.WriteLine("USERS LIST RECIVED FOR CHANNEL {0}", users.channel_id);
                    Console.WriteLine("COUNT(users) = {0}", users.users_count);
                };

                gg.OnGetChannelsList += (sender, channels) => {
                    Console.WriteLine("CHANNELS LIST RECIVED");
                    Console.WriteLine("COUT(channels) = {0}", channels.channels.Count);

                    var channel = channels.channels.First();
                    Console.WriteLine("FIRST CHANNEL ID: {0}", channel.channel_id);
                };

                gg.OnMessageRecieved += (sender, message) => {
                    Console.WriteLine("MESSAGE {0}: {1}", message.user_name, message.text);
                };

                gg.Connect();
                //gg.GetChannelsList(0, 2);

                gg.GetUsersList(6147);
                gg.Join(6147);

                Console.ReadKey(true);

                gg.Unjoin(6147);
                Console.WriteLine("CLOSE CONNECTION");
            }

            Console.WriteLine(GG.GetChannelId("BSP"));
            Console.ReadKey(true);
        }
Esempio n. 2
0
        private void Button_Connect(object sender, RoutedEventArgs e)
        {
            var streamer = StreamerNameInput.Text;

            if (streamer == "")
            {
                MessageBox.Show("Введите имя стримера");
                return;
            }

            try {
                if (_userListUpdateTimer != null)
                {
                    _userListUpdateTimer.Dispose();
                }

                if (_xTimer != null)
                {
                    _xTimer.Stop();
                }

                var id = GG.GetChannelId(streamer);

                if (_manager != null)
                {
                    _manager.Dispose();
                }

                _manager = new ConnectionManager(id);
                BindingOperations.ClearBinding(usersListView, ListView.ItemsSourceProperty);
                var usersBind = new Binding();
                usersBind.Source = _manager.users;
                usersListView.SetBinding(ListView.ItemsSourceProperty, usersBind);

                BindingOperations.ClearBinding(chatControl, ListView.ItemsSourceProperty);
                var chatBind = new Binding();
                chatBind.Source = _manager.messages;
                chatControl.SetBinding(ListView.ItemsSourceProperty, chatBind);

                BindingOperations.ClearBinding(whiteUsersListView, ListView.ItemsSourceProperty);
                var premiumBind = new Binding();
                premiumBind.Source = _manager.WhiteList;
                whiteUsersListView.SetBinding(ListView.ItemsSourceProperty, premiumBind);

                //BindingOperations.ClearBinding(blackUsersListView, ListView.ItemsSourceProperty);
                //var blackListBind = new Binding();
                //blackListBind.Source = _manager.BlackList;
                //blackUsersListView.SetBinding(ListView.ItemsSourceProperty, blackListBind);

                BindingOperations.ClearBinding(forRandowUsersListView, ListView.ItemsSourceProperty);
                var forRandomBind = new Binding();
                forRandomBind.Source = _manager.ForRandom;
                forRandowUsersListView.SetBinding(ListView.ItemsSourceProperty, forRandomBind);

                cb_pem.UserList    = (FilteredList <User>)_manager.WhiteList;
                cb_nonpem.UserList = (FilteredList <User>)_manager.WhiteList;
                cb_donat0.UserList = (FilteredList <User>)_manager.WhiteList;
                cb_donat1.UserList = (FilteredList <User>)_manager.WhiteList;
                cb_donat2.UserList = (FilteredList <User>)_manager.WhiteList;
                cb_donat3.UserList = (FilteredList <User>)_manager.WhiteList;
                cb_donat4.UserList = (FilteredList <User>)_manager.WhiteList;
                cb_donat5.UserList = (FilteredList <User>)_manager.WhiteList;
                cb_mod.UserList    = (FilteredList <User>)_manager.WhiteList;

                _userListUpdateTimer          = new Timer();
                _userListUpdateTimer.Interval = 5000;
                _userListUpdateTimer.Elapsed += new ElapsedEventHandler(OnUpdateUserList);
                _userListUpdateTimer.Enabled  = true;

                _xTimer.Start();
            } catch (Exception) {
                MessageBox.Show("Что-то пошло не так. Найдите последовательность действий, приводящих к этому сообщению и отправьте её на [email protected]");
            }
        }