public override void HandleMessage(Streams.XmppStream stream, Message msg, XmppHandlerContext context)
        {
            //Private msg
            if (msg.Type==MessageType.chat)
            {
                if (Member.ResolveRoomJid(msg.From)==null)
                {
                    //Error
                    msg.SwitchDirection();
                    msg.From = Member.RoomFrom;
                    msg.Type = MessageType.error;
                    msg.Error = new Error(ErrorCondition.ItemNotFound);
                    context.Sender.SendTo(stream, msg);
                }
                else
                {
                    //Send
                    msg.To = Member.RealJid;
                    msg.From = Member.ResolveRoomJid(msg.From);
                    Member.Send(msg);
                }

            }
            else
            {
                msg.SwitchDirection();
                msg.From = Member.RoomFrom;
                msg.Type = MessageType.error;
                msg.Error = new Error(ErrorCondition.BadRequest);
                context.Sender.SendTo(stream, msg);
            }
        }
        public override void HandleMessage(ASC.Xmpp.Server.Streams.XmppStream stream, Message msg, XmppHandlerContext context)
        {
            msg.SwitchDirection();
            msg.Type = MessageType.error;
            msg.Error = new Error(ErrorType.cancel, ErrorCondition.ItemNotFound);
            context.Sender.SendTo(stream, msg);

        }
Example #3
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);
			}
		}
        public override void HandleMessage(Streams.XmppStream stream, Message msg, XmppHandlerContext context)
        {
            User user = (User) msg.SelectSingleElement(typeof (User));
            if (user != null)
            {
                HandleUserMessage(msg, user, stream);
            }
            else
            {
                //Groupchat message
                MucRoomMember member = Room.GetRealMember(msg.From);
                if (member != null && ReferenceEquals(member.Stream, stream) && member.Role != Role.none)
                {
                    if (msg.Type == MessageType.groupchat)
                    {
                        if (msg.Subject!=null)
                        {
                            Room.ChangeSubject(member, msg.Subject);
                        }
                        else
                        {
                            MessageBroadcast(msg, member);    
                        }
                    }
                    else
                    {
                        msg.SwitchDirection();
                        msg.Type = MessageType.error;
                        msg.Error = new Error(ErrorCondition.NotAcceptable);
                        context.Sender.SendTo(stream, msg);
                    }
                }
                else
                {
                    msg.SwitchDirection();
                    msg.Type = MessageType.error;
                    msg.Error = new Error(ErrorCondition.Forbidden);
                    context.Sender.SendTo(stream, msg);
                }
            }

        }