Beispiel #1
0
        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" });
        }
Beispiel #2
0
        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);
            });
        }
Beispiel #3
0
        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);
        }
Beispiel #4
0
        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 OpenGroupChannelList()
    {
        foreach (UnityEngine.Object btnGroupChannel in btnGroupChannels)
        {
            GameObject.Destroy(btnGroupChannel);
        }
        btnGroupChannels.Clear();

        groupChannelListPanel.SetActive(true);

        mGroupChannelListQuery       = GroupChannel.CreateMyGroupChannelListQuery();
        mGroupChannelListQuery.Limit = 50;
        LoadGroupChannels();
    }
Beispiel #6
0
    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();
            }
        });
    }
Beispiel #7
0
        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);
        }