KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > xmpp > muc > Invitation


1 /**
2  * $RCSfile: Invitation.java,v $
3  * $Revision: 1.1 $
4  * $Date: 2005/02/06 20:02:22 $
5  *
6  * Copyright 2004 Jive Software.
7  *
8  * All rights reserved. Licensed under the Apache License, Version 2.0 (the "License");
9  * you may not use this file except in compliance with the License.
10  * You may obtain a copy of the License at
11  *
12  * http://www.apache.org/licenses/LICENSE-2.0
13  *
14  * Unless required by applicable law or agreed to in writing, software
15  * distributed under the License is distributed on an "AS IS" BASIS,
16  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17  * See the License for the specific language governing permissions and
18  * limitations under the License.
19  */

20
21 package org.xmpp.muc;
22
23 import org.dom4j.Element;
24 import org.xmpp.packet.Message;
25
26 /**
27  * Represents an invitation to a Multi-User Chat room from a room occupant to a user that is not
28  * an occupant of the room. The invitation must be <b>sent to the room</b> and it's the room
29  * responsibility to forward the invitation to the invitee. The <b>sender of the invitation must be
30  * the real full JID of the inviter</b>.<p>
31  *
32  * Code example:
33  * <pre>
34  * // Invite the someone to the room.
35  * Invitation invitation = new Invitation("invitee@jabber.org", "Join this excellent room");
36  * invitation.setTo("room@conference.jabber.org");
37  * invitation.setFrom("inviter@jabber.org/notebook");
38  *
39  * component.sendPacket(invitation);
40  * </pre>
41  *
42  * @author Gaston Dombiak
43  */

44 public class Invitation extends Message {
45
46     /**
47      * Creates a new invitation.
48      *
49      * @param invitee the XMPP address of the invitee. The room will forward the invitation to this
50      * address.
51      * @param reason the reason why the invitation is being sent.
52      */

53     public Invitation(String JavaDoc invitee, String JavaDoc reason) {
54         super();
55         Element element = addChildElement("x", "http://jabber.org/protocol/muc#user");
56         Element invite = element.addElement("invite");
57         invite.addAttribute("to", invitee);
58         if (reason != null && reason.length() > 0) {
59             invite.addElement("reason").setText(reason);
60         }
61     }
62 }
63
Popular Tags