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); }
static void Main(string[] args) { var gg = new GG(); var welcome = gg.Connect(); while (!welcome.IsCompleted) { System.Threading.Thread.Sleep(1); } Console.WriteLine("GG say welcome!"); Console.ReadLine(); }
public ConnectionManager(int channel_id) { _channelId = channel_id; #region List initializations _users = new ObservableCollection <User>(); _messages = new ObservableCollection <Message>(); // Чёрный список _blackList.CollectionChanged += _blackList_CollectionChanged; // Группа пользователей для отбора для розыгрыша _whiteList = new FilteredList <User>(_users); _whiteList.Observe(_blackList); //_whiteList.AddDeselector(new Selectors.BlackListSelector(_blackList)); ChatActive = new ObservableCollection <User>(); // Составляем список людей для розыгрыша _ForRandom = new FilteredList <User>(_users); _ForRandom.Observe(_blackList); _ForRandom.Observe(_whiteList); _ForRandom.AddSelector(new Selectors.WhiteListSelector(_whiteList)); _ForRandom.AddDeselector(new Selectors.InChatDeselector(ChatActive)); #endregion _gg = new GG(); #region GG API Callbacks _gg.OnGetWelcome += (sender, welcome) => { _gg.GetUsersList(channel_id); _gg.Join(channel_id); }; _gg.OnGetUsersList += (sender, usersList) => { if (_users.Count == 0) { foreach (var u in usersList.users) { _users.Add(u); } } else { foreach (var u in usersList.users) { if (!_users.Contains(u, new UserEqualityComparer())) { _users.Add(u); } } } _whiteList.Updated(); }; _gg.OnMessageRecieved += (sender, message) => { _messages.Add(message); var user = new User { id = message.user_id, name = message.user_name }; if (!_blackList.Any(U => U.id == user.id)) { //if (!_forRandom.Any(U => U.id == user.id)) { // _forRandom.Add(user); //} if (!ChatActive.Any(U => U.id == user.id)) { ChatActive.Add(user); } } _whiteList.Updated(); }; #endregion _gg.Connect(); }