Пример #1
0
        /// <summary>
        /// 响应客户端添加结果
        /// </summary>
        private void OnToClientAdd(MobaClient client, bool result, int requestId)
        {
            MobaClient requestClient = playerCache.GetClient(requestId);

            if (result == true)
            {
                //同意了保存数据
                int playerId = playerCache.GetId(client);
                playerCache.AddFriend(playerId, requestId);
                Send(client, OpCode.PlayerCode, OpPlayer.ToClientAdd, 1, "添加成功", JsonMapper.ToJson(ToDto(playerCache.GetModel(playerId))));
                Send(requestClient, OpCode.PlayerCode, OpPlayer.ToClientAdd, 1, "添加成功", JsonMapper.ToJson(ToDto(playerCache.GetModel(requestId))));
            }
            else
            {
                //拒绝了,回传原来的客户端不同意
                Send(requestClient, OpCode.PlayerCode, OpPlayer.ToClientAdd, -1, "拒绝添加好友");
            }
        }
Пример #2
0
        /// <summary>
        /// 添加结果
        /// </summary>
        private void onToClientAdd(MobaClient client, bool result, int requestId)
        {
            MobaClient requestClient = playerCache.GetClient(requestId);

            //同意 保存数据
            if (result == true)
            {
                int playerId = playerCache.GetId(client);
                playerCache.AddFriend(playerId, requestId);
                Send(client, OpCode.PlayerCode, OpPlayer.ToClientAdd, 1, "添加成功", JsonMapper.ToJson(toDto(playerCache.GetModel(playerId))));
                Send(requestClient, OpCode.PlayerCode, OpPlayer.ToClientAdd, 1, "添加成功", JsonMapper.ToJson(toDto(playerCache.GetModel(requestId))));
                return;
            }
            else
            {
                //拒绝了 回传给原来的客户端告诉他 不同意
                Send(requestClient, OpCode.PlayerCode, OpPlayer.ToClientAdd, -1, "此玩家拒绝你的请求");
            }
        }
Пример #3
0
        /// <summary>
        /// 添加好友结果的处理
        /// </summary>
        /// <param name="result"></param>
        private void OnAddFriendToClient(MOBAClient client, bool result, int requestID)
        {
            MOBAClient requestClient = playerCache.GetClient(requestID);

            if (result)
            {
                //同意了,保存数据
                int playerID = playerCache.GetID(client);
                playerCache.AddFriend(playerID, requestID);
                Send(client, OperationCode.PlayerCode, OpPlayer.AddFriendToClient, 1, "添加成功",
                     JsonMapper.ToJson(ToDto(playerCache.GetPlayerModel(client))));
                Send(requestClient, OperationCode.PlayerCode, OpPlayer.AddFriendToClient, 1, "添加成功",
                     JsonMapper.ToJson(ToDto(playerCache.GetPlayerModel(requestClient))));
            }
            else
            {
                //拒绝了,就回传给原来的客户端,告诉他被拒绝了
                Send(requestClient, OperationCode.PlayerCode, OpPlayer.AddFriendToClient, -1, "此玩家拒绝你的请求");
            }
        }