public void DataInit() { if (Users.Count > 0) { Users.Clear(); } GroupChannelListQuery mQuery = GroupChannel.CreateMyGroupChannelListQuery(); mQuery.IncludeEmpty = true; mQuery.Next((List <GroupChannel> list, SendBirdException e) => { if (e != null) { // Error. return; } foreach (GroupChannel channel in list) { foreach (User user in channel.Members) { if (user.UserId != Settings.ChatID) { Users.Add(new UserInfo { ChatID = user.UserId, FirstName = user.Nickname, Icon = user.ProfileUrl, Homeland = ((UserMessage)channel.LastMessage).Message, Address = MilsecToDatetime(channel.LastMessage.CreatedAt).ToShortTimeString()//ToString() }); } } } }); //Users.Add(new Models.User { ChatID = "cycbis_006", FirstName = "Thomas Wong" }); }
public void ListGroupChannels() { _cache.GroupChannels.Clear(); //TODO - build reuse functionality for refreshing - when required //TODO check connection state and try to login again if connection closed List <ChannelInfo> _channels = new List <ChannelInfo>(); GroupChannelListQuery mQuery = GroupChannel.CreateMyGroupChannelListQuery(); mQuery.IncludeEmpty = true; mQuery.Next((List <GroupChannel> list, SendBirdException e1) => { if (e1 != null) { HandleException(e1); return; //TODO check if we need to flag an error event here - incase any waiting services } _channels.AddRange(PojoConverter.Transform(list)); _cache.GroupChannels.AddRange(list); LogMessage("OnListGroupChannels"); _completionHandler.OnListGroupChannels(_channels); }); }
public Task <GroupChannel> GetCurrentChannel(string userId) { var tcs = new TaskCompletionSource <GroupChannel>(); GroupChannelListQuery filteredQuery = GroupChannel.CreateMyGroupChannelListQuery(); if (filteredQuery == null) { tcs.TrySetCanceled(); return(tcs.Task); } filteredQuery.SetUserIdsExactFilter(new List <string> { userId }); filteredQuery.Next((List <GroupChannel> queryResult, SendBirdException e) => { if (e != null) { tcs.TrySetCanceled(); } else { tcs.TrySetResult(queryResult.FirstOrDefault()); } }); return(tcs.Task); }
public Task <List <GroupChannel> > GetAllChannels() { var tcs = new TaskCompletionSource <List <GroupChannel> >(); GroupChannelListQuery mQuery = GroupChannel.CreateMyGroupChannelListQuery(); if (mQuery == null) { tcs.TrySetCanceled(); return(tcs.Task); } mQuery.IncludeEmpty = false; mQuery.Order = GroupChannelListQuery.ChannelListOrder.LATEST_LAST_MESSAGE; mQuery.Next((List <GroupChannel> list, SendBirdException e) => { if (e != null) { tcs.TrySetCanceled(); } else { tcs.TrySetResult(list); } }); Debug.WriteLine("Getting Sendbird ALL Channels"); return(tcs.Task); }
void LoadGroupChannels() { mGroupChannelListQuery.Next((list, e) => { if (e != null) { Debug.Log(e.Code + ": " + e.Message); return; } foreach (GroupChannel groupChannel in list) { GameObject btnGroupChannel = Instantiate(channelListItemPrefab) as GameObject; btnGroupChannel.GetComponent <Image>().sprite = uiTheme.channelButtonOff; btnGroupChannel.GetComponent <Image>().type = Image.Type.Sliced; if (groupChannel.Url == selectedChannelUrl) { btnGroupChannel.GetComponent <Image>().overrideSprite = uiTheme.channelButtonOn; btnGroupChannel.GetComponentInChildren <Text>().color = uiTheme.channelButtonOnColor; } else { btnGroupChannel.GetComponent <Image>().overrideSprite = null; btnGroupChannel.GetComponentInChildren <Text>().color = uiTheme.channelButtonOffColor; } btnGroupChannel.transform.SetParent(groupChannelListGridPanel.transform); btnGroupChannel.transform.localScale = Vector3.one; Text text = btnGroupChannel.GetComponentInChildren <Text>(); text.text = string.Format("{0}:{1} ({2})", groupChannel.Name, GetDisplayMemberNames(groupChannel.Members), groupChannel.UnreadMessageCount); btnGroupChannels.Add(btnGroupChannel); GroupChannel final = groupChannel; btnGroupChannel.GetComponent <Button>().onClick.AddListener(() => { groupChannelListPanel.SetActive(false); groupChannelPanel.SetActive(true); currentChannel = final; editableScrollArea.SetActive(true); groupScrollArea.SetActive(false); LoadGroupChannelPreviousChatHistory(); }); } }); }
public void GetListOfFriends() { friendsGroupChannel = new List <GroupChannel>(); friendsUserList = new List <User>(); mGroupChannelListQuery = GroupChannel.CreateMyGroupChannelListQuery(); mGroupChannelListQuery.Limit = 50; mGroupChannelListQuery.Next((list, e) => { if (e != null) { Debug.Log(e.Code + ": " + e.Message); return; } foreach (GroupChannel groupChannel in list) { foreach (User user in groupChannel.Members) { if (!user.Nickname.Equals(userName)) { friendsGroupChannel.Add(groupChannel); friendsUserList.Add(user); var index = nearByPeople.FindIndex(i => i.Nickname == user.Nickname); if (index >= 0) { // ensure item found nearByPeople.RemoveAt(index); } break; } } } Debug.Log("Number of friends " + friendsUserList.Count); if (friendsScreen.isConnect) { friendsScreen.RefreshFriends(); } }); }
public Task <List <GroupChannel> > GetChannels(List <string> users) { var tcs = new TaskCompletionSource <List <GroupChannel> >(); GroupChannelListQuery filteredQuery = GroupChannel.CreateMyGroupChannelListQuery(); filteredQuery.IncludeEmpty = false; filteredQuery.SetUserIdsIncludeFilter(users, GroupChannelListQuery.QueryType.OR); filteredQuery.Next((List <GroupChannel> queryResult, SendBirdException e) => { if (e != null) { tcs.TrySetCanceled(); } else { tcs.TrySetResult(queryResult); } }); Debug.WriteLine("Getting Channels with users"); return(tcs.Task); }