Aura.Msgr.Network.Send.FriendInviteR C# (CSharp) Method

FriendInviteR() public static method

Response to FriendInvite.
public static FriendInviteR ( MsgrClient client, FriendInviteResult result, Aura.Msgr.Database.Friend friend = null ) : void
client MsgrClient
result FriendInviteResult
friend Aura.Msgr.Database.Friend Required for success, otherwise can be left null.
return void
		public static void FriendInviteR(MsgrClient client, FriendInviteResult result, Friend friend = null)
		{
			if (result == FriendInviteResult.Success && friend == null)
				throw new ArgumentNullException("friend");

			var packet = new Packet(Op.Msgr.FriendInviteR, 0);

			//packet.PutInt((int)result);
			packet.PutInt((int)result);
			if (result == FriendInviteResult.Success)
			{
				packet.PutInt(friend.Id);
				packet.PutString(friend.FullName);
				packet.PutByte((byte)friend.FriendshipStatus);
			}

			client.Send(packet);
		}

Usage Example

Exemplo n.º 1
0
        public void PlayerBlock(MsgrClient client, Packet packet)
        {
            var characterName = packet.GetString();
            var serverName    = packet.GetString();

            // Get user
            var friend = MsgrServer.Instance.Database.GetFriendFromUser(characterName, serverName);

            if (friend == null)
            {
                Send.FriendInviteR(client, FriendInviteResult.UserNotFound);
                return;
            }

            // Check account
            if (friend.AccountId == client.User.AccountId)
            {
                Send.FriendInviteR(client, FriendInviteResult.OwnAccount);
                return;
            }

            // Check existing friends
            if (client.User.Friends.Exists(a => a.Id == friend.Id))
            {
                Send.FriendInviteR(client, FriendInviteResult.AlreadyFriends);
                return;
            }

            // Check max friends
            var max = MsgrServer.Instance.Conf.Msgr.MaxFriends;

            if (max != 0 && client.User.Friends.Count >= max)
            {
                Send.FriendInviteR(client, FriendInviteResult.MaxReached);
                return;
            }

            friend.FriendshipStatus = FriendshipStatus.Blacklist;

            // Add
            client.User.Friends.Add(friend);
            MsgrServer.Instance.Database.Blacklist(client.User.Id, friend.Id);

            Send.FriendInviteR(client, FriendInviteResult.Success, friend);
        }
All Usage Examples Of Aura.Msgr.Network.Send::FriendInviteR