Ejemplo n.º 1
0
        private BnetEntityId ExtractEntityIdFromFriendNotification(byte[] payload)
        {
            FriendNotification friendNotification = FriendNotification.ParseFrom(payload);

            if (!friendNotification.IsInitialized)
            {
                return(null);
            }
            return(BnetEntityId.CreateFromProtocol(friendNotification.Target.Id));
        }
Ejemplo n.º 2
0
 BattlenetRpcErrorCode HandleOnFriendRemoved(FriendNotification request)
 {
     Log.outError(LogFilter.ServiceProtobuf, "{0} Client tried to call not implemented method FriendsListener.OnFriendRemoved: {1}",
                  GetCallerInfo(), request.ToString());
     return(BattlenetRpcErrorCode.RpcNotImplemented);
 }
Ejemplo n.º 3
0
        public override void CallServerMethod(uint token, uint methodId, CodedInputStream stream)
        {
            switch (methodId)
            {
            case 1:
            {
                FriendNotification request = new FriendNotification();
                request.MergeFrom(stream);


                BattlenetRpcErrorCode status = HandleOnFriendAdded(request);
                Log.outDebug(LogFilter.ServiceProtobuf, "{0} Client called server method FriendsListener.OnFriendAdded(bgs.protocol.friends.v1.FriendNotification: {1}) status: {2}.",
                             GetCallerInfo(), request.ToString(), status);
                if (status != 0)
                {
                    SendResponse(token, status);
                }
                break;
            }

            case 2:
            {
                FriendNotification request = new FriendNotification();
                request.MergeFrom(stream);


                BattlenetRpcErrorCode status = HandleOnFriendRemoved(request);
                Log.outDebug(LogFilter.ServiceProtobuf, "{0} Client called server method FriendsListener.OnFriendRemoved(bgs.protocol.friends.v1.FriendNotification: {1}) status: {2}.",
                             GetCallerInfo(), request.ToString(), status);
                if (status != 0)
                {
                    SendResponse(token, status);
                }
                break;
            }

            case 3:
            {
                InvitationNotification request = new InvitationNotification();
                request.MergeFrom(stream);


                BattlenetRpcErrorCode status = HandleOnReceivedInvitationAdded(request);
                Log.outDebug(LogFilter.ServiceProtobuf, "{0} Client called server method FriendsListener.OnReceivedInvitationAdded(bgs.protocol.friends.v1.InvitationNotification: {1}) status: {2}.",
                             GetCallerInfo(), request.ToString(), status);
                if (status != 0)
                {
                    SendResponse(token, status);
                }
                break;
            }

            case 4:
            {
                InvitationNotification request = new InvitationNotification();
                request.MergeFrom(stream);


                BattlenetRpcErrorCode status = HandleOnReceivedInvitationRemoved(request);
                Log.outDebug(LogFilter.ServiceProtobuf, "{0} Client called server method FriendsListener.OnReceivedInvitationRemoved(bgs.protocol.friends.v1.InvitationNotification: {1}) status: {2}.",
                             GetCallerInfo(), request.ToString(), status);
                if (status != 0)
                {
                    SendResponse(token, status);
                }
                break;
            }

            case 5:
            {
                InvitationNotification request = new InvitationNotification();
                request.MergeFrom(stream);


                BattlenetRpcErrorCode status = HandleOnSentInvitationAdded(request);
                Log.outDebug(LogFilter.ServiceProtobuf, "{0} Client called server method FriendsListener.OnSentInvitationAdded(bgs.protocol.friends.v1.InvitationNotification: {1}) status: {2}.",
                             GetCallerInfo(), request.ToString(), status);
                if (status != 0)
                {
                    SendResponse(token, status);
                }
                break;
            }

            case 6:
            {
                InvitationNotification request = new InvitationNotification();
                request.MergeFrom(stream);


                BattlenetRpcErrorCode status = HandleOnSentInvitationRemoved(request);
                Log.outDebug(LogFilter.ServiceProtobuf, "{0} Client called server method FriendsListener.OnSentInvitationRemoved(bgs.protocol.friends.v1.InvitationNotification: {1}) status: {2}.",
                             GetCallerInfo(), request.ToString(), status);
                if (status != 0)
                {
                    SendResponse(token, status);
                }
                break;
            }

            case 7:
            {
                UpdateFriendStateNotification request = new UpdateFriendStateNotification();
                request.MergeFrom(stream);


                BattlenetRpcErrorCode status = HandleOnUpdateFriendState(request);
                Log.outDebug(LogFilter.ServiceProtobuf, "{0} Client called server method FriendsListener.OnUpdateFriendState(bgs.protocol.friends.v1.UpdateFriendStateNotification: {1}) status: {2}.",
                             GetCallerInfo(), request.ToString(), status);
                if (status != 0)
                {
                    SendResponse(token, status);
                }
                break;
            }

            default:
                Log.outError(LogFilter.ServiceProtobuf, "Bad method id {0}.", methodId);
                SendResponse(token, BattlenetRpcErrorCode.RpcInvalidMethod);
                break;
            }
        }
Ejemplo n.º 4
0
 public override void NotifyFriendRemoved(Google.ProtocolBuffers.IRpcController controller, FriendNotification request, Action <bnet.protocol.NO_RESPONSE> done)
 {
     throw new NotImplementedException();
 }
Ejemplo n.º 5
0
		public override void NotifyFriendRemoved(Google.ProtocolBuffers.IRpcController controller, FriendNotification request, Action<bnet.protocol.NO_RESPONSE> done) {
			throw new NotImplementedException();
		}
Ejemplo n.º 6
0
        public async Task SendAddPerson(string from, string to, string msg)
        {
            string uid    = string.Empty;
            string connId = string.Empty;

            if (UserIdByClient.ContainsKey(Context.ConnectionId))
            {
                uid = UserIdByClient[Context.ConnectionId];
            }

            if (ClientByUserId.ContainsKey(to))
            {
                connId = ClientByUserId[to];
            }

            var model = FriendNotificationRepository.Find(f =>
                                                          (f.FromUserId == new Guid(from) && f.ToUserId == new Guid(to)) || (f.FromUserId == new Guid(to) && f.ToUserId == new Guid(from))
                                                          ).FirstOrDefault();

            if (model == null)
            {
                //通知添加到数据库
                model            = new FriendNotification();
                model.Id         = Guid.NewGuid();
                model.State      = 1;
                model.FromUserId = new Guid(uid);
                model.FromUser   = UsersRepository.Load(model.FromUserId);
                model.ToUserId   = new Guid(to);
                model.ToUser     = UsersRepository.Load(model.ToUserId);
                model.Message    = msg;
                model.CreateTime = DateTime.Now;
                model.UpdateTime = DateTime.Now;

                FriendNotificationRepository.Add(model);
                FriendNotificationRepository.SaveChanges();
            }
            else
            {
                if (model.State != 3)
                {
                    model.State      = 1;
                    model.Message    = msg;
                    model.UpdateTime = DateTime.Now;

                    FriendNotificationRepository.SaveChanges();
                }
            }

            if (new Guid(uid) == model.ToUserId)
            {
                await Clients.Client(Context.ConnectionId).SendAsync("OnlineCallbackFunc", "你们已经是好友了,无法重复添加");
            }
            else
            {
                AddFriend friend = new AddFriend();
                friend.Id         = model.Id.ToString().ToLower();
                friend.Type       = MessageType.AddUser;
                friend.FromUid    = uid;
                friend.ToUid      = to;
                friend.Message    = msg;
                friend.State      = model.State;
                friend.UserName   = model.FromUser.UserName;
                friend.NickName   = model.FromUser.NickName;
                friend.HeadImg    = model.FromUser.HeadImg;
                friend.CreateTime = model.FromUser.CreateTime;
                friend.UpdateTime = model.FromUser.UpdateTime;

                if (!string.IsNullOrEmpty(connId) && model.State == 1)
                {
                    await Clients.Client(connId).SendAsync("ClientNoticeRemind", friend.ToJsonString());
                }
            }
        }