public Promise <Dictionary <string, FriendsController.UserStatus> > GetFriendList()
    {
        if (friendListPromise == null)
        {
            friendListPromise = new Promise <Dictionary <string, FriendsController.UserStatus> >();
        }

        if (friendsController == null)
        {
            return(friendListPromise);
        }

        if (isFriendlistDirty && friendsController.isInitialized)
        {
            isFriendlistDirty        = false;
            waitingFriendsInitialize = false;
            friendListPromise.Resolve(friendsController.GetFriends());
        }

        if (waitingFriendsInitialize)
        {
            waitingFriendsInitialize         = false;
            friendsController.OnInitialized += OnFriendsInitialized;
        }

        return(friendListPromise);
    }
예제 #2
0
 private void SearchUserStatus(string userId)
 {
     if (currentFriendsController.GetFriends().TryGetValue(userId, out currentUserStatus))
     {
         UpdateInfo(
             currentUserStatus.position,
             currentUserStatus.realm != null ? currentUserStatus.realm.serverName : string.Empty,
             currentUserStatus.realm != null ? currentUserStatus.realm.layer : string.Empty,
             currentUserStatus.presence);
     }
 }
예제 #3
0
    void OnFriendsInitialized()
    {
        friendsController.OnInitialized -= OnFriendsInitialized;

        using (var friendsIterator = friendsController.GetFriends().GetEnumerator())
        {
            while (friendsIterator.MoveNext())
            {
                FriendTracker friend = new FriendTracker(friendsIterator.Current.Key, friendColors[Random.Range(0, friendColors.Length)]);
                friend.SetStatus(friendsIterator.Current.Value);
                friends.Add(friendsIterator.Current.Key, friend);
            }
        }

        using (var listenersIterator = listeners.GetEnumerator())
        {
            while (listenersIterator.MoveNext())
            {
                ProcessNewListener(listenersIterator.Current.Value);
            }
        }
    }
예제 #4
0
    internal ChatHeadButton AddChatHead(string userId, ulong timestamp, bool saveStatusInStorage = true)
    {
        var existingHead = chatHeads.FirstOrDefault(x => x.profile.userId == userId);

        if (existingHead != null)
        {
            existingHead.lastTimestamp = timestamp;
            SortChatHeads();

            if (saveStatusInStorage)
            {
                LatestOpenChatsList.Model existingHeadInStorage = CommonScriptableObjects.latestOpenChats.GetList().FirstOrDefault(c => c.userId == userId);
                if (existingHeadInStorage != null)
                {
                    existingHeadInStorage.lastTimestamp = timestamp;
                    SaveLatestOpenChats();
                }
            }

            return(existingHead);
        }

        GameObject     prefab   = Resources.Load(CHAT_HEAD_PATH) as GameObject;
        GameObject     instance = Instantiate(prefab, container);
        ChatHeadButton chatHead = instance.GetComponent <ChatHeadButton>();

        chatHead.Initialize(UserProfileController.userProfilesCatalog.Get(userId));
        chatHead.lastTimestamp = timestamp;
        chatHead.OnToggleOn   += OnToggleOn;
        chatHead.OnToggleOff  += OnToggleOff;

        if (friendsController != null &&
            friendsController.GetFriends().TryGetValue(userId, out FriendsController.UserStatus friendStatus))
        {
            chatHead.SetOnlineStatus(friendStatus.presence == PresenceStatus.ONLINE);
        }

        var animator = chatHead.GetComponent <ShowHideAnimator>();

        if (animator != null)
        {
            animator.Show();
        }

        chatHeads.Add(chatHead);
        SortChatHeads();

        if (saveStatusInStorage)
        {
            CommonScriptableObjects.latestOpenChats.Add(new LatestOpenChatsList.Model {
                userId = userId, lastTimestamp = timestamp
            });
            SaveLatestOpenChats();
        }

        if (chatHeads.Count > MAX_GROUP_SIZE)
        {
            var lastChatHead = chatHeads[chatHeads.Count - 1];
            RemoveChatHead(lastChatHead, saveStatusInStorage);
        }

        return(chatHead);
    }