Exemple #1
0
    //收到获取好友列表协议
    private void OnMsgGetFriendList(Request request)
    {
        MsgGetFriendList msgGetFriendList = MsgGetFriendList.Parser.ParseFrom(request.Msg);

        string[] fl = msgGetFriendList.FriendList.Split(',');
        foreach (string friendId in fl)
        {
            if ((!_friendList.Contains(friendId)) && friendId != "")
            {
                _friendList.Add(friendId);
            }
        }


        UpdataFriendList();
    }
Exemple #2
0
    //显示
    public override void OnShow(params object[] args)
    {
        //寻找组件
        _closeBtn        = skin.transform.Find("CloseBtn").GetComponent <Button>();
        _friendListPanel = skin.transform.Find("FriendListPanel/Scroll View/Viewport/Content").gameObject;
        _searchPanel     = skin.transform.Find("SearchPanel").gameObject;
        _idInput         = _searchPanel.transform.Find("IdInput").GetComponent <InputField>();
        _addFriendBtn    = _searchPanel.transform.Find("AddFriendBtn").GetComponent <Button>();
        //监听
        _closeBtn.onClick.AddListener(OnCloseClick);
        _addFriendBtn.onClick.AddListener(OnAddFriendClick);
        //网络协议监听
        NetManager.AddMsgListener("MsgGetFriendList", OnMsgGetFriendList);
        NetManager.AddMsgListener("MsgDeleteFriend", OnMsgDeleteFriend);
        NetManager.AddMsgListener("MsgAddFriend", OnMsgAddFriend);
        NetManager.AddMsgListener("MsgAcceptAddFriend", OnMsgAcceptAddFriend);
        //发送获取好友列表协议
        MsgGetFriendList msgGetFriendList = new MsgGetFriendList();

        NetManager.Send(msgGetFriendList);
    }