예제 #1
0
        private GraphChangeStatus addFriend(GDID gNode, GDID gFriendNode, bool?approve, FriendshipRequestDirection direction)
        {
            GraphChangeStatus result;
            var ctx = ForNode(gNode);
            var row = ctx.LoadRow(Queries.FindOneFriendByNodeAndFriend <FriendRow>(gNode, gFriendNode));

            if (row != null)
            {
                if (approve == null)
                {
                    return(GraphChangeStatus.Updated);
                }
                row.Status      = approve.Value ? GSFriendStatus.APPROVED : GSFriendStatus.DENIED;
                row.Status_Date = App.TimeSource.UTCNow;
                ctx.Update(row);
                result = GraphChangeStatus.Updated;
            }
            else
            {
                row = new FriendRow(true)
                {
                    G_Owner      = gNode,
                    G_Friend     = gFriendNode,
                    Status_Date  = App.TimeSource.UTCNow,
                    Status       = approve != null && approve.Value ? GSFriendStatus.APPROVED: GSFriendStatus.PENDING,
                    Visibility   = GSFriendVisibility.FRIENDS,
                    Request_Date = App.TimeSource.UTCNow,
                    Direction    = GSFriendshipRequestDirection.ToDomainString(direction)
                };
                ctx.Insert(row);
                result = GraphChangeStatus.Added;
            }
            return(result);
        }
예제 #2
0
    protected FriendTag GetFriendTag(FriendRow info)
    {
        FriendTag item = TagsPooling.GetItem();

        Tags.Enqueue(item);

        if (IsAlreadyFriend(info))
        {
            item.RemoveButton.gameObject.SetActive(true);
            item.Add_AcceptButon.gameObject.SetActive(false);
        }
        else
        {
            if (IsWaitingAccept(info))
            {
                item.RemoveButton.gameObject.SetActive(true);
                if (!info.RequestBool)
                {
                    item.Add_AcceptButon.gameObject.SetActive(true);
                }
                else
                {
                    item.Add_AcceptButon.gameObject.SetActive(false);
                }
            }
            else if (IsWaitingUnFriend(info))
            {
                item.RemoveButton.gameObject.SetActive(false);
                item.Add_AcceptButon.gameObject.SetActive(false);
            }
        }

        return(item);
    }
예제 #3
0
    public override void Load(params object[] input)
    {
        JSONTable_Friends  friends = SyncData.FriendTable;
        JSONTable_UserInfo users   = SyncData.UserInfos;

        UserInfoRow user = null;

        for (int i = 0; i < friends.Count; i++)
        {
            FriendRow friendInfo = friends.ReadOnlyRows[i];

            if (IsAlreadyFriend(friendInfo))
            {
                user = users.GetUserById(friendInfo.ID_Player);

                FriendTag tag = GetFriendTag(friendInfo);

                tag.UserName.text = user.NameInGame;

                tag.RemoveButton.OnClickEvents += delegate
                {
                    OnUnfriendButton(friendInfo);
                    ReleaseTag(tag);
                };

                tag.gameObject.SetActive(true);
            }
        }
    }
예제 #4
0
    protected void OnRejectButton(FriendRow info)
    {
        SetFocusFriendInfo(info);
        Debugger.Log(SyncData.UserInfos.GetUserById(info.ID_Player).NameInGame + " " + info.ID_Player);

        FriendListeners.Emit("S_REJECT_FRIEND");

        SyncData.FriendTable.RemoveById(info.ID_Player);
    }
예제 #5
0
    protected void OnAddFriendButton(FriendRow info)
    {
        SetFocusFriendInfo(info);
        info.AcceptTime = 24.0f * 3600; // 24h
        info.RemoveTime = 0.0f;
        Debugger.Log(SyncData.UserInfos.GetUserById(info.ID_Player).NameInGame + " " + info.ID_Player);
        FriendListeners.Emit("S_ADD_FRIEND");

        SyncData.FriendTable.UpdateFriendInfo(info);
    }
예제 #6
0
    protected void OnUnfriendButton(FriendRow info)
    {
        SetFocusFriendInfo(info);

        info.AcceptTime = 0.0f;
        info.RemoveTime = 1800.0f; // 30'
        Debugger.Log(SyncData.UserInfos.GetUserById(info.ID_Player).NameInGame + " " + info.ID_Player);

        FriendListeners.Emit("S_UNFRIEND");

        SyncData.FriendTable.UpdateFriendInfo(info);
    }
예제 #7
0
파일: RequestFunc.cs 프로젝트: dqtoy/Assets
    public override void Load(params object[] input)
    {
        JSONTable_Friends  friends = SyncData.FriendTable;
        JSONTable_UserInfo users   = SyncData.UserInfos;

        for (int i = 0; i < friends.Count; i++)
        {
            FriendRow info = friends.ReadOnlyRows[i];
            if (info.AcceptTime != 0.0f)
            {
                UserInfoRow user = users.GetUserById(info.ID_Player);
                AddFriendTag(info, user);
            }
        }
    }
예제 #8
0
    private void OnFindFriendButton()
    {
        ReleaseFriendTags();
        string userName = UserNameInput.Text;

        if (string.IsNullOrEmpty(userName))
        {
            Debugger.Log("player name is empty");
            return;
        }

        JSONTable_UserInfo users     = SyncData.UserInfos;
        UserInfoRow        foundUser = users.GetUserByName(userName);

        if (foundUser != null)
        {
            FriendRow friendInfo = FriendTable.GetFriendInfoById(foundUser.ID_User);
            if (friendInfo == null)
            {
                if (foundUser.ID_User != SyncData.User_ID)
                {
                    CreateFriendTag
                    (
                        new FriendRow()
                    {
                        ID_Player   = foundUser.ID_User,
                        RequestBool = true,
                    },
                        foundUser,
                        false
                    );
                }
            }
            else
            {
                CreateFriendTag
                (
                    friendInfo,
                    foundUser,
                    true
                );
            }
        }
        else
        {
            NotFoundMessage.gameObject.SetActive(true);
        }
    }
예제 #9
0
파일: FriendSys.cs 프로젝트: dqtoy/Assets
    private void R_ACCEPT_FRIEND(SocketIOEvent obj)
    {
        Debugger.Log(obj.data["R_ACCEPT_FRIEND"]);
        int idAccept = -1;

        obj.data.GetField(ref idAccept, "R_ACCEPT_FRIEND");

        if (idAccept != -1)
        {
            FriendRow info = new FriendRow()
            {
                ID_Player   = idAccept,
                AcceptTime  = 0,
                RemoveTime  = 0,
                RequestBool = false,
            };
            friends.UpdateFriendInfo(info);
            NotifyAll();
        }
    }
예제 #10
0
파일: RequestFunc.cs 프로젝트: dqtoy/Assets
    private void AddFriendTag(FriendRow info, UserInfoRow user)
    {
        FriendTag tag = GetFriendTag(info);

        tag.UserName.text = user.NameInGame;
        tag.Describe.text = "Waiting " + info.AcceptTimeString();

        tag.RemoveButton.OnClickEvents += delegate
        {
            OnRejectButton(info);
            ReleaseTag(tag);
        };

        if (!info.RequestBool)
        {
            //tag.Add_AcceptButon.gameObject.SetActive(true);
            tag.Add_AcceptButon.OnClickEvents += delegate
            {
                OnAcceptButton(info);
                ReleaseTag(tag);
            };
        }
        tag.gameObject.SetActive(true);
    }
예제 #11
0
 protected bool IsWaitingAccept(FriendRow info)
 {
     return(info.AcceptTime != 0.0f);
 }
예제 #12
0
        public void Update(bool clearSelection = true)
        {
            if (clearSelection)
                SelectedFriend = null;

            for (int i = 0; i < Rows.Length; i++)
            {
                if (Rows[i] != null) Rows[i].Dispose();

                Rows[i] = null;
            }

            List<ClientFriend> filteredFriends = new List<ClientFriend>();

            if (_blockedTab)
                filteredFriends = Friends.Where(e => e.Blocked).ToList();
            else
                filteredFriends = Friends.Where(e => !e.Blocked).ToList();

            int maxPage = filteredFriends.Count / Rows.Length + 1;
            if (maxPage < 1) maxPage = 1;

            PageNumberLabel.Text = (Page + 1) + " / " + maxPage;

            int maxIndex = filteredFriends.Count - 1;

            if (StartIndex > maxIndex) StartIndex = maxIndex;
            if (StartIndex < 0) StartIndex = 0;

            for (int i = 0; i < Rows.Length; i++)
            {
                if (i + StartIndex >= filteredFriends.Count) break;

                if (Rows[i] != null)
                    Rows[i].Dispose();

                Rows[i] = new FriendRow
                {
                    Friend = filteredFriends[i + StartIndex],
                    Location = new Point((i % 2) * 115 + 16, 55 + ((i) / 2) * 22),
                    Parent = this,
                };
                Rows[i].Click += (o, e) =>
                {
                    FriendRow row = (FriendRow)o;

                    if (row.Friend != SelectedFriend)
                    {
                        SelectedFriend = row.Friend;
                        SelectedIndex = FindSelectedIndex();
                        UpdateRows();
                    }
                };

                if (SelectedFriend != null)
                {
                    if (SelectedIndex == i)
                    {
                        SelectedFriend = Rows[i].Friend;
                    }
                }
            }
        }
예제 #13
0
    private void CreateFriendTag(FriendRow friendInfo, UserInfoRow userInfo, bool isExisted)
    {
        FriendTag tag = GetFriendTag(friendInfo);

        tag.UserName.text = userInfo.NameInGame;

        if (isExisted)
        {
            bool alreadyFriend = IsAlreadyFriend(friendInfo);
            bool waitingAccept = IsWaitingAccept(friendInfo);
            bool waitingRemove = IsWaitingUnFriend(friendInfo);

            tag.UserName.text = userInfo.NameInGame;


            if (alreadyFriend)
            {
                tag.RemoveButton.OnClickEvents += delegate
                {
                    OnUnfriendButton(friendInfo);
                    ReleaseTag(tag);
                };
            }
            else if (waitingAccept)
            {
                tag.RemoveButton.OnClickEvents += delegate
                {
                    OnRejectButton(friendInfo);
                    ReleaseTag(tag);
                };
                tag.Add_AcceptButon.OnClickEvents += delegate
                {
                    OnAcceptButton(friendInfo);
                    ReleaseTag(tag);
                };
            }
            //else if(waitingRemove)
            //{
            //    tag.RemoveButton.gameObject.SetActive(false);
            //    tag.Add_AcceptButon.gameObject.SetActive(false);
            //}

            string acceptTime = friendInfo.AcceptTime != 0.0f ? "Waiting " + friendInfo.AcceptTimeString() : null;
            string removeTime = friendInfo.RemoveTime != 0.0f ? "Removing " + friendInfo.RemoveTimeString() : null;

            tag.Describe.text = acceptTime + removeTime;
        }
        else
        {
            // doesn't friend
            tag.RemoveButton.gameObject.SetActive(false);
            tag.Add_AcceptButon.gameObject.SetActive(true);

            tag.Add_AcceptButon.OnClickEvents += delegate
            {
                OnAddFriendButton(friendInfo);
                ReleaseTag(tag);
            };
        }
        tag.gameObject.SetActive(true);
    }
예제 #14
0
 public void SetFocusFriendInfo(FriendRow info)
 {
     focusInfo = info;
 }
예제 #15
0
파일: FriendSys.cs 프로젝트: dqtoy/Assets
    public bool IsMyFriend(int id)
    {
        FriendRow f = friends.GetFriendInfoById(id);

        return(f != null);
    }
예제 #16
0
 protected void SetFocusFriendInfo(FriendRow info)
 {
     FriendListeners.SetFocusFriendInfo(info);
 }
예제 #17
0
 protected bool IsWaitingUnFriend(FriendRow info)
 {
     return(info.RemoveTime != 0.0f);
 }
예제 #18
0
 protected bool IsAlreadyFriend(FriendRow info)
 {
     return(info.AcceptTime == 0.0f && info.RemoveTime == 0.0f);
 }