Exemplo n.º 1
0
		public void InviteUser(Message msg, User user, XmppStream stream)
		{
			if (RoomSettings.CanInvite)
			{
				Message inviteMsg = new Message(user.Invite.To, Jid, MessageType.normal, null);
				User userElement = new User();
				userElement.Invite = new Invite();

				MucRoomMember member = GetRealMember(msg.From);
				userElement.Invite.From = member == null ? msg.From : member.Jid;
				userElement.Invite.Reason = user.Invite.Reason;
				inviteMsg.RemoveAllChildNodes();
				inviteMsg.AddChild(userElement);

				if (!Send(inviteMsg))
				{
					// Return error
					msg.SwitchDirection();
					msg.Type = MessageType.error;
					msg.Error = new Error(ErrorType.cancel, ErrorCondition.ItemNotFound);
					Sender.SendTo(stream, msg);
				}
			}
			else
			{
				msg.SwitchDirection();
				msg.Type = MessageType.error;
				msg.Error = new Error(ErrorType.cancel, ErrorCondition.NotAllowed);
				Sender.SendTo(stream, msg);
			}
		}
Exemplo n.º 2
0
		public void DeclinedUser(Message msg, User user, XmppStream stream)
		{
			Message declineMsg = new Message(user.Decline.To, Jid, MessageType.normal, null);
			User userElement = new User();
			userElement.Decline = new Decline();
			userElement.Decline.From = msg.From;
			userElement.Decline.Reason = user.Decline.Reason;
			declineMsg.RemoveAllChildNodes();
			declineMsg.AddChild(userElement);
			Send(declineMsg);
		}