public class MultiUserChat extends Object
Constructor and Description |
---|
MultiUserChat(XMPPConnection connection,
String room)
Creates a new multi user chat with the specified connection and room name.
|
Modifier and Type | Method and Description |
---|---|
static void |
addInvitationListener(XMPPConnection conn,
InvitationListener listener)
Adds a listener to invitation notifications.
|
void |
addInvitationRejectionListener(InvitationRejectionListener listener)
Adds a listener to invitation rejections notifications.
|
void |
addMessageListener(PacketListener listener)
Adds a packet listener that will be notified of any new messages in the
group chat.
|
void |
addParticipantListener(PacketListener listener)
Adds a packet listener that will be notified of any new Presence packets
sent to the group chat.
|
void |
addParticipantStatusListener(ParticipantStatusListener listener)
Adds a listener that will be notified of changes in occupants status in the room
such as the user being kicked, banned, or granted admin permissions.
|
void |
addPresenceInterceptor(PacketInterceptor presenceInterceptor)
Adds a new
PacketInterceptor that will be invoked every time a new presence
is going to be sent by this MultiUserChat to the server. |
void |
addSubjectUpdatedListener(SubjectUpdatedListener listener)
Adds a listener to subject change notifications.
|
void |
addUserStatusListener(UserStatusListener listener)
Adds a listener that will be notified of changes in your status in the room
such as the user being kicked, banned, or granted admin permissions.
|
void |
banUser(String jid,
String reason)
Bans a user from the room.
|
void |
banUsers(Collection<String> jids)
Bans users from the room.
|
void |
changeAvailabilityStatus(String status,
Presence.Mode mode)
Changes the occupant's availability status within the room.
|
void |
changeNickname(String nickname)
Changes the occupant's nickname to a new nickname within the room.
|
void |
changeSubject(String subject)
Changes the subject within the room.
|
void |
create(String nickname)
Creates the room according to some default configuration, assign the requesting user as the
room owner, and add the owner to the room but not allow anyone else to enter the room
(effectively "locking" the room).
|
Message |
createMessage()
Creates a new Message to send to the chat room.
|
boolean |
createOrJoin(String nickname)
Like
create(String) , but will return true if the room creation was acknowledged by
the service (with an 201 status code). |
Chat |
createPrivateChat(String occupant,
MessageListener listener)
Returns a new Chat for sending private messages to a given room occupant.
|
static void |
decline(XMPPConnection conn,
String room,
String inviter,
String reason)
Informs the sender of an invitation that the invitee declines the invitation.
|
void |
destroy(String reason,
String alternateJID)
Sends a request to the server to destroy the room.
|
protected void |
finalize() |
Collection<Affiliate> |
getAdmins()
Returns a collection of
Affiliate with the room administrators. |
Form |
getConfigurationForm()
Returns the room's configuration form that the room's owner can use or null if
no configuration is possible.
|
static Collection<HostedRoom> |
getHostedRooms(XMPPConnection connection,
String serviceName)
Returns a collection of HostedRooms where each HostedRoom has the XMPP address of the room
and the room's name.
|
static List<String> |
getJoinedRooms(XMPPConnection connection,
String user)
Returns a List of the rooms where the requested user has joined.
|
Collection<Affiliate> |
getMembers()
Returns a collection of
Affiliate with the room members. |
Collection<Occupant> |
getModerators()
Returns a collection of
Occupant with the room moderators. |
String |
getNickname()
Returns the nickname that was used to join the room, or null if not
currently joined.
|
Occupant |
getOccupant(String user)
Returns the Occupant information for a particular occupant, or null if the
user is not in the room.
|
Presence |
getOccupantPresence(String user)
Returns the presence info for a particular user, or null if the user
is not in the room.
|
List<String> |
getOccupants()
Returns an Iterator (of Strings) for the list of fully qualified occupants
in the group chat.
|
int |
getOccupantsCount()
Returns the number of occupants in the group chat.
|
Collection<Affiliate> |
getOutcasts()
Returns a collection of
Affiliate with the room outcasts. |
Collection<Affiliate> |
getOwners()
Returns a collection of
Affiliate with the room owners. |
Collection<Occupant> |
getParticipants()
Returns a collection of
Occupant with the room participants. |
Form |
getRegistrationForm()
Returns the room's registration form that an unaffiliated user, can use to become a member
of the room or null if no registration is possible.
|
String |
getReservedNickname()
Returns the reserved room nickname for the user in the room.
|
String |
getRoom()
Returns the name of the room this MultiUserChat object represents.
|
static RoomInfo |
getRoomInfo(XMPPConnection connection,
String room)
Returns the discovered information of a given room without actually having to join the room.
|
static Collection<String> |
getServiceNames(XMPPConnection connection)
Returns a collection with the XMPP addresses of the Multi-User Chat services.
|
String |
getSubject()
Returns the last known room's subject or null if the user hasn't joined the room
or the room does not have a subject yet.
|
void |
grantAdmin(Collection<String> jids)
Grants administrator privileges to other users.
|
void |
grantAdmin(String jid)
Grants administrator privileges to another user.
|
void |
grantMembership(Collection<String> jids)
Grants membership to other users.
|
void |
grantMembership(String jid)
Grants membership to a user.
|
void |
grantModerator(Collection<String> nicknames)
Grants moderator privileges to participants or visitors.
|
void |
grantModerator(String nickname)
Grants moderator privileges to a participant or visitor.
|
void |
grantOwnership(Collection<String> jids)
Grants ownership privileges to other users.
|
void |
grantOwnership(String jid)
Grants ownership privileges to another user.
|
void |
grantVoice(Collection<String> nicknames)
Grants voice to visitors in the room.
|
void |
grantVoice(String nickname)
Grants voice to a visitor in the room.
|
void |
invite(Message message,
String user,
String reason)
Invites another user to the room in which one is an occupant using a given Message.
|
void |
invite(String user,
String reason)
Invites another user to the room in which one is an occupant.
|
boolean |
isJoined()
Returns true if currently in the multi user chat (after calling the
join(String) method). |
static boolean |
isServiceEnabled(XMPPConnection connection,
String user)
Returns true if the specified user supports the Multi-User Chat protocol.
|
void |
join(String nickname)
Joins the chat room using the specified nickname.
|
void |
join(String nickname,
String password)
Joins the chat room using the specified nickname and password.
|
void |
join(String nickname,
String password,
DiscussionHistory history,
long timeout)
Joins the chat room using the specified nickname and password.
|
void |
kickParticipant(String nickname,
String reason)
Kicks a visitor or participant from the room.
|
void |
leave()
Leave the chat room.
|
Message |
nextMessage()
Returns the next available message in the chat.
|
Message |
nextMessage(long timeout)
Returns the next available message in the chat.
|
Message |
pollMessage()
Polls for and returns the next message, or null if there isn't
a message immediately available.
|
static void |
removeInvitationListener(XMPPConnection conn,
InvitationListener listener)
Removes a listener to invitation notifications.
|
void |
removeInvitationRejectionListener(InvitationRejectionListener listener)
Removes a listener from invitation rejections notifications.
|
void |
removeMessageListener(PacketListener listener)
Removes a packet listener that was being notified of any new messages in the
multi user chat.
|
void |
removeParticipantListener(PacketListener listener)
Remoces a packet listener that was being notified of any new Presence packets
sent to the group chat.
|
void |
removeParticipantStatusListener(ParticipantStatusListener listener)
Removes a listener that was being notified of changes in occupants status in the room
such as the user being kicked, banned, or granted admin permissions.
|
void |
removePresenceInterceptor(PacketInterceptor presenceInterceptor)
Removes a
PacketInterceptor that was being invoked every time a new presence
was being sent by this MultiUserChat to the server. |
void |
removeSubjectUpdatedListener(SubjectUpdatedListener listener)
Removes a listener from subject change notifications.
|
void |
removeUserStatusListener(UserStatusListener listener)
Removes a listener that was being notified of changes in your status in the room
such as the user being kicked, banned, or granted admin permissions.
|
void |
revokeAdmin(Collection<String> jids)
Revokes administrator privileges from users.
|
void |
revokeAdmin(String jid)
Revokes administrator privileges from a user.
|
void |
revokeMembership(Collection<String> jids)
Revokes users' membership.
|
void |
revokeMembership(String jid)
Revokes a user's membership.
|
void |
revokeModerator(Collection<String> nicknames)
Revokes moderator privileges from other users.
|
void |
revokeModerator(String nickname)
Revokes moderator privileges from another user.
|
void |
revokeOwnership(Collection<String> jids)
Revokes ownership privileges from other users.
|
void |
revokeOwnership(String jid)
Revokes ownership privileges from another user.
|
void |
revokeVoice(Collection<String> nicknames)
Revokes voice from participants in the room.
|
void |
revokeVoice(String nickname)
Revokes voice from a participant in the room.
|
void |
sendConfigurationForm(Form form)
Sends the completed configuration form to the server.
|
void |
sendMessage(Message message)
Sends a Message to the chat room.
|
void |
sendMessage(String text)
Sends a message to the chat room.
|
void |
sendRegistrationForm(Form form)
Sends the completed registration form to the server.
|
public MultiUserChat(XMPPConnection connection, String room)
join
the chat room. On some server implementations,
the room will not be created until the first person joins it.Most XMPP servers use a sub-domain for the chat service (eg chat.example.com for the XMPP server example.com). You must ensure that the room address you're trying to connect to includes the proper chat sub-domain.
connection
- the XMPP connection.room
- the name of the room in the form "roomName@service", where
"service" is the hostname at which the multi-user chat
service is running. Make sure to provide a valid JID.public static boolean isServiceEnabled(XMPPConnection connection, String user) throws SmackException.NoResponseException, XMPPException.XMPPErrorException, SmackException.NotConnectedException
connection
- the connection to use to perform the service discovery.user
- the user to check. A fully qualified xmpp ID, e.g. jdoe@example.com.XMPPException.XMPPErrorException
SmackException.NoResponseException
SmackException.NotConnectedException
public static List<String> getJoinedRooms(XMPPConnection connection, String user) throws SmackException.NoResponseException, XMPPException.XMPPErrorException, SmackException.NotConnectedException
connection
- the connection to use to perform the service discovery.user
- the user to check. A fully qualified xmpp ID, e.g. jdoe@example.com.XMPPException.XMPPErrorException
SmackException.NoResponseException
SmackException.NotConnectedException
public static RoomInfo getRoomInfo(XMPPConnection connection, String room) throws SmackException.NoResponseException, XMPPException.XMPPErrorException, SmackException.NotConnectedException
connection
- the XMPP connection to use for discovering information about the room.room
- the name of the room in the form "roomName@service" of which we want to discover
its information.XMPPException.XMPPErrorException
SmackException.NoResponseException
SmackException.NotConnectedException
public static Collection<String> getServiceNames(XMPPConnection connection) throws SmackException.NoResponseException, XMPPException.XMPPErrorException, SmackException.NotConnectedException
connection
- the XMPP connection to use for discovering Multi-User Chat services.XMPPException.XMPPErrorException
SmackException.NoResponseException
SmackException.NotConnectedException
public static Collection<HostedRoom> getHostedRooms(XMPPConnection connection, String serviceName) throws SmackException.NoResponseException, XMPPException.XMPPErrorException, SmackException.NotConnectedException
connection
- the XMPP connection to use for discovering hosted rooms by the MUC service.serviceName
- the service that is hosting the rooms to discover.XMPPException.XMPPErrorException
SmackException.NoResponseException
SmackException.NotConnectedException
public String getRoom()
public void create(String nickname) throws SmackException.NoResponseException, XMPPException.XMPPErrorException, SmackException
To create an "Instant Room", that means a room with some default configuration that is
available for immediate access, the room's owner should send an empty form after creating the
room. sendConfigurationForm(Form)
To create a "Reserved Room", that means a room manually configured by the room creator before
anyone is allowed to enter, the room's owner should complete and send a form after creating
the room. Once the completed configuration form is sent to the server, the server will unlock
the room. sendConfigurationForm(Form)
nickname
- the nickname to use.XMPPException.XMPPErrorException
- if the room couldn't be created for some reason (e.g. 405 error if
the user is not allowed to create the room)SmackException.NoResponseException
- if there was no response from the server.SmackException
- If the creation failed because of a missing acknowledge from the
server, e.g. because the room already existed.public boolean createOrJoin(String nickname) throws SmackException.NoResponseException, XMPPException.XMPPErrorException, SmackException
create(String)
, but will return true if the room creation was acknowledged by
the service (with an 201 status code). It's up to the caller to decide, based on the return
value, if he needs to continue sending the room configuration. If false is returned, the room
already existed and the user is able to join right away, without sending a form.nickname
- the nickname to use.XMPPException.XMPPErrorException
- if the room couldn't be created for some reason (e.g. 405 error if
the user is not allowed to create the room)SmackException.NoResponseException
- if there was no response from the server.SmackException
public void join(String nickname) throws SmackException.NoResponseException, XMPPException.XMPPErrorException, SmackException.NotConnectedException
nickname
- the nickname to use.SmackException.NoResponseException
XMPPException.XMPPErrorException
- if an error occurs joining the room. In particular, a
401 error can occur if no password was provided and one is required; or a
403 error can occur if the user is banned; or a
404 error can occur if the room does not exist or is locked; or a
407 error can occur if user is not on the member list; or a
409 error can occur if someone is already in the group chat with the same nickname.SmackException.NoResponseException
- if there was no response from the server.SmackException.NotConnectedException
public void join(String nickname, String password) throws XMPPException.XMPPErrorException, SmackException
A password is required when joining password protected rooms. If the room does not require a password there is no need to provide one.
nickname
- the nickname to use.password
- the password to use.XMPPException.XMPPErrorException
- if an error occurs joining the room. In particular, a
401 error can occur if no password was provided and one is required; or a
403 error can occur if the user is banned; or a
404 error can occur if the room does not exist or is locked; or a
407 error can occur if user is not on the member list; or a
409 error can occur if someone is already in the group chat with the same nickname.SmackException
- if there was no response from the server.public void join(String nickname, String password, DiscussionHistory history, long timeout) throws XMPPException.XMPPErrorException, SmackException.NoResponseException, SmackException.NotConnectedException
To control the amount of history to receive while joining a room you will need to provide a configured DiscussionHistory object.
A password is required when joining password protected rooms. If the room does not require a password there is no need to provide one.
If the room does not already exist when the user seeks to enter it, the server will decide to create a new room or not.
nickname
- the nickname to use.password
- the password to use.history
- the amount of discussion history to receive while joining a room.timeout
- the amount of time to wait for a reply from the MUC service(in milleseconds).XMPPException.XMPPErrorException
- if an error occurs joining the room. In particular, a
401 error can occur if no password was provided and one is required; or a
403 error can occur if the user is banned; or a
404 error can occur if the room does not exist or is locked; or a
407 error can occur if user is not on the member list; or a
409 error can occur if someone is already in the group chat with the same nickname.SmackException.NoResponseException
- if there was no response from the server.SmackException.NotConnectedException
public boolean isJoined()
join(String)
method).public void leave() throws SmackException.NotConnectedException
public Form getConfigurationForm() throws SmackException.NoResponseException, XMPPException.XMPPErrorException, SmackException.NotConnectedException
XMPPException.XMPPErrorException
- if an error occurs asking the configuration form for the room.SmackException.NoResponseException
- if there was no response from the server.SmackException.NotConnectedException
public void sendConfigurationForm(Form form) throws SmackException.NoResponseException, XMPPException.XMPPErrorException, SmackException.NotConnectedException
form
- the form with the new settings.XMPPException.XMPPErrorException
- if an error occurs setting the new rooms' configuration.SmackException.NoResponseException
- if there was no response from the server.SmackException.NotConnectedException
public Form getRegistrationForm() throws SmackException.NoResponseException, XMPPException.XMPPErrorException, SmackException.NotConnectedException
If the user requesting registration requirements is not allowed to register with the room (e.g. because that privilege has been restricted), the room will return a "Not Allowed" error to the user (error code 405).
XMPPException.XMPPErrorException
- if an error occurs asking the registration form for the room or a
405 error if the user is not allowed to register with the room.SmackException.NoResponseException
- if there was no response from the server.SmackException.NotConnectedException
public void sendRegistrationForm(Form form) throws SmackException.NoResponseException, XMPPException.XMPPErrorException, SmackException.NotConnectedException
If the desired room nickname is already reserved for that room, the room will return a "Conflict" error to the user (error code 409). If the room does not support registration, it will return a "Service Unavailable" error to the user (error code 503).
form
- the completed registration form.XMPPException.XMPPErrorException
- if an error occurs submitting the registration form. In particular, a
409 error can occur if the desired room nickname is already reserved for that room;
or a 503 error can occur if the room does not support registration.SmackException.NoResponseException
- if there was no response from the server.SmackException.NotConnectedException
public void destroy(String reason, String alternateJID) throws SmackException.NoResponseException, XMPPException.XMPPErrorException, SmackException.NotConnectedException
reason
- the reason for the room destruction.alternateJID
- the JID of an alternate location.XMPPException.XMPPErrorException
- if an error occurs while trying to destroy the room.
An error can occur which will be wrapped by an XMPPException --
XMPP error code 403. The error code can be used to present more
appropiate error messages to end-users.SmackException.NoResponseException
- if there was no response from the server.SmackException.NotConnectedException
public void invite(String user, String reason) throws SmackException.NotConnectedException
If the room is password-protected, the invitee will receive a password to use to join the room. If the room is members-only, the the invitee may be added to the member list.
user
- the user to invite to the room.(e.g. hecate@shakespeare.lit)reason
- the reason why the user is being invited.SmackException.NotConnectedException
public void invite(Message message, String user, String reason) throws SmackException.NotConnectedException
If the room is password-protected, the invitee will receive a password to use to join the room. If the room is members-only, the the invitee may be added to the member list.
message
- the message to use for sending the invitation.user
- the user to invite to the room.(e.g. hecate@shakespeare.lit)reason
- the reason why the user is being invited.SmackException.NotConnectedException
public static void decline(XMPPConnection conn, String room, String inviter, String reason) throws SmackException.NotConnectedException
conn
- the connection to use for sending the rejection.room
- the room that sent the original invitation.inviter
- the inviter of the declined invitation.reason
- the reason why the invitee is declining the invitation.SmackException.NotConnectedException
public static void addInvitationListener(XMPPConnection conn, InvitationListener listener)
conn
- the connection where the listener will be applied.listener
- an invitation listener.public static void removeInvitationListener(XMPPConnection conn, InvitationListener listener)
conn
- the connection where the listener was applied.listener
- an invitation listener.public void addInvitationRejectionListener(InvitationRejectionListener listener)
listener
- an invitation rejection listener.public void removeInvitationRejectionListener(InvitationRejectionListener listener)
listener
- an invitation rejection listener.public void addSubjectUpdatedListener(SubjectUpdatedListener listener)
listener
- a subject updated listener.public void removeSubjectUpdatedListener(SubjectUpdatedListener listener)
listener
- a subject updated listener.public void addPresenceInterceptor(PacketInterceptor presenceInterceptor)
PacketInterceptor
that will be invoked every time a new presence
is going to be sent by this MultiUserChat to the server. Packet interceptors may
add new extensions to the presence that is going to be sent to the MUC service.presenceInterceptor
- the new packet interceptor that will intercept presence packets.public void removePresenceInterceptor(PacketInterceptor presenceInterceptor)
PacketInterceptor
that was being invoked every time a new presence
was being sent by this MultiUserChat to the server. Packet interceptors may
add new extensions to the presence that is going to be sent to the MUC service.presenceInterceptor
- the packet interceptor to remove.public String getSubject()
To be notified every time the room's subject change you should add a listener
to this room. addSubjectUpdatedListener(SubjectUpdatedListener)
To change the room's subject use changeSubject(String)
.
public String getReservedNickname() throws SmackException
SmackException
- if there was no response from the server.public String getNickname()
public void changeNickname(String nickname) throws SmackException.NoResponseException, XMPPException.XMPPErrorException, SmackException.NotConnectedException
nickname
- the new nickname within the room.XMPPException.XMPPErrorException
- if the new nickname is already in use by another occupant.SmackException.NoResponseException
- if there was no response from the server.SmackException.NotConnectedException
public void changeAvailabilityStatus(String status, Presence.Mode mode) throws SmackException.NotConnectedException
status
- a text message describing the presence update.mode
- the mode type for the presence update.SmackException.NotConnectedException
public void kickParticipant(String nickname, String reason) throws XMPPException.XMPPErrorException, SmackException.NoResponseException, SmackException.NotConnectedException
nickname
- the nickname of the participant or visitor to kick from the room
(e.g. "john").reason
- the reason why the participant or visitor is being kicked from the room.XMPPException.XMPPErrorException
- if an error occurs kicking the occupant. In particular, a
405 error can occur if a moderator or a user with an affiliation of "owner" or "admin"
was intended to be kicked (i.e. Not Allowed error); or a
403 error can occur if the occupant that intended to kick another occupant does
not have kicking privileges (i.e. Forbidden error); or a
400 error can occur if the provided nickname is not present in the room.SmackException.NoResponseException
- if there was no response from the server.SmackException.NotConnectedException
public void grantVoice(Collection<String> nicknames) throws XMPPException.XMPPErrorException, SmackException.NoResponseException, SmackException.NotConnectedException
nicknames
- the nicknames of the visitors to grant voice in the room (e.g. "john").XMPPException.XMPPErrorException
- if an error occurs granting voice to a visitor. In particular, a
403 error can occur if the occupant that intended to grant voice is not
a moderator in this room (i.e. Forbidden error); or a
400 error can occur if the provided nickname is not present in the room.SmackException.NoResponseException
- if there was no response from the server.SmackException.NotConnectedException
public void grantVoice(String nickname) throws XMPPException.XMPPErrorException, SmackException.NoResponseException, SmackException.NotConnectedException
nickname
- the nickname of the visitor to grant voice in the room (e.g. "john").XMPPException.XMPPErrorException
- if an error occurs granting voice to a visitor. In particular, a
403 error can occur if the occupant that intended to grant voice is not
a moderator in this room (i.e. Forbidden error); or a
400 error can occur if the provided nickname is not present in the room.SmackException.NoResponseException
- if there was no response from the server.SmackException.NotConnectedException
public void revokeVoice(Collection<String> nicknames) throws XMPPException.XMPPErrorException, SmackException.NoResponseException, SmackException.NotConnectedException
nicknames
- the nicknames of the participants to revoke voice (e.g. "john").XMPPException.XMPPErrorException
- if an error occurs revoking voice from a participant. In particular, a
405 error can occur if a moderator or a user with an affiliation of "owner" or "admin"
was tried to revoke his voice (i.e. Not Allowed error); or a
400 error can occur if the provided nickname is not present in the room.SmackException.NoResponseException
- if there was no response from the server.SmackException.NotConnectedException
public void revokeVoice(String nickname) throws XMPPException.XMPPErrorException, SmackException.NoResponseException, SmackException.NotConnectedException
nickname
- the nickname of the participant to revoke voice (e.g. "john").XMPPException.XMPPErrorException
- if an error occurs revoking voice from a participant. In particular, a
405 error can occur if a moderator or a user with an affiliation of "owner" or "admin"
was tried to revoke his voice (i.e. Not Allowed error); or a
400 error can occur if the provided nickname is not present in the room.SmackException.NoResponseException
- if there was no response from the server.SmackException.NotConnectedException
public void banUsers(Collection<String> jids) throws XMPPException.XMPPErrorException, SmackException.NoResponseException, SmackException.NotConnectedException
jids
- the bare XMPP user IDs of the users to ban.XMPPException.XMPPErrorException
- if an error occurs banning a user. In particular, a
405 error can occur if a moderator or a user with an affiliation of "owner" or "admin"
was tried to be banned (i.e. Not Allowed error).SmackException.NoResponseException
- if there was no response from the server.SmackException.NotConnectedException
public void banUser(String jid, String reason) throws XMPPException.XMPPErrorException, SmackException.NoResponseException, SmackException.NotConnectedException
jid
- the bare XMPP user ID of the user to ban (e.g. "user@host.org").reason
- the optional reason why the user was banned.XMPPException.XMPPErrorException
- if an error occurs banning a user. In particular, a
405 error can occur if a moderator or a user with an affiliation of "owner" or "admin"
was tried to be banned (i.e. Not Allowed error).SmackException.NoResponseException
- if there was no response from the server.SmackException.NotConnectedException
public void grantMembership(Collection<String> jids) throws XMPPException.XMPPErrorException, SmackException.NoResponseException, SmackException.NotConnectedException
jids
- the XMPP user IDs of the users to grant membership.XMPPException.XMPPErrorException
- if an error occurs granting membership to a user.SmackException.NoResponseException
- if there was no response from the server.SmackException.NotConnectedException
public void grantMembership(String jid) throws XMPPException.XMPPErrorException, SmackException.NoResponseException, SmackException.NotConnectedException
jid
- the XMPP user ID of the user to grant membership (e.g. "user@host.org").XMPPException.XMPPErrorException
- if an error occurs granting membership to a user.SmackException.NoResponseException
- if there was no response from the server.SmackException.NotConnectedException
public void revokeMembership(Collection<String> jids) throws XMPPException.XMPPErrorException, SmackException.NoResponseException, SmackException.NotConnectedException
jids
- the bare XMPP user IDs of the users to revoke membership.XMPPException.XMPPErrorException
- if an error occurs revoking membership to a user.SmackException.NoResponseException
- if there was no response from the server.SmackException.NotConnectedException
public void revokeMembership(String jid) throws XMPPException.XMPPErrorException, SmackException.NoResponseException, SmackException.NotConnectedException
jid
- the bare XMPP user ID of the user to revoke membership (e.g. "user@host.org").XMPPException.XMPPErrorException
- if an error occurs revoking membership to a user.SmackException.NoResponseException
- if there was no response from the server.SmackException.NotConnectedException
public void grantModerator(Collection<String> nicknames) throws XMPPException.XMPPErrorException, SmackException.NoResponseException, SmackException.NotConnectedException
nicknames
- the nicknames of the occupants to grant moderator privileges.XMPPException.XMPPErrorException
- if an error occurs granting moderator privileges to a user.SmackException.NoResponseException
- if there was no response from the server.SmackException.NotConnectedException
public void grantModerator(String nickname) throws XMPPException.XMPPErrorException, SmackException.NoResponseException, SmackException.NotConnectedException
nickname
- the nickname of the occupant to grant moderator privileges.XMPPException.XMPPErrorException
- if an error occurs granting moderator privileges to a user.SmackException.NoResponseException
- if there was no response from the server.SmackException.NotConnectedException
public void revokeModerator(Collection<String> nicknames) throws XMPPException.XMPPErrorException, SmackException.NoResponseException, SmackException.NotConnectedException
nicknames
- the nicknames of the occupants to revoke moderator privileges.XMPPException.XMPPErrorException
- if an error occurs revoking moderator privileges from a user.SmackException.NoResponseException
- if there was no response from the server.SmackException.NotConnectedException
public void revokeModerator(String nickname) throws XMPPException.XMPPErrorException, SmackException.NoResponseException, SmackException.NotConnectedException
nickname
- the nickname of the occupant to revoke moderator privileges.XMPPException.XMPPErrorException
- if an error occurs revoking moderator privileges from a user.SmackException.NoResponseException
- if there was no response from the server.SmackException.NotConnectedException
public void grantOwnership(Collection<String> jids) throws XMPPException.XMPPErrorException, SmackException.NoResponseException, SmackException.NotConnectedException
jids
- the collection of bare XMPP user IDs of the users to grant ownership.XMPPException.XMPPErrorException
- if an error occurs granting ownership privileges to a user.SmackException.NoResponseException
- if there was no response from the server.SmackException.NotConnectedException
public void grantOwnership(String jid) throws XMPPException.XMPPErrorException, SmackException.NoResponseException, SmackException.NotConnectedException
jid
- the bare XMPP user ID of the user to grant ownership (e.g. "user@host.org").XMPPException.XMPPErrorException
- if an error occurs granting ownership privileges to a user.SmackException.NoResponseException
- if there was no response from the server.SmackException.NotConnectedException
public void revokeOwnership(Collection<String> jids) throws XMPPException.XMPPErrorException, SmackException.NoResponseException, SmackException.NotConnectedException
jids
- the bare XMPP user IDs of the users to revoke ownership.XMPPException.XMPPErrorException
- if an error occurs revoking ownership privileges from a user.SmackException.NoResponseException
- if there was no response from the server.SmackException.NotConnectedException
public void revokeOwnership(String jid) throws XMPPException.XMPPErrorException, SmackException.NoResponseException, SmackException.NotConnectedException
jid
- the bare XMPP user ID of the user to revoke ownership (e.g. "user@host.org").XMPPException.XMPPErrorException
- if an error occurs revoking ownership privileges from a user.SmackException.NoResponseException
- if there was no response from the server.SmackException.NotConnectedException
public void grantAdmin(Collection<String> jids) throws XMPPException.XMPPErrorException, SmackException.NoResponseException, SmackException.NotConnectedException
jids
- the bare XMPP user IDs of the users to grant administrator privileges.XMPPException.XMPPErrorException
- if an error occurs granting administrator privileges to a user.SmackException.NoResponseException
- if there was no response from the server.SmackException.NotConnectedException
public void grantAdmin(String jid) throws XMPPException.XMPPErrorException, SmackException.NoResponseException, SmackException.NotConnectedException
jid
- the bare XMPP user ID of the user to grant administrator privileges
(e.g. "user@host.org").XMPPException.XMPPErrorException
- if an error occurs granting administrator privileges to a user.SmackException.NoResponseException
- if there was no response from the server.SmackException.NotConnectedException
public void revokeAdmin(Collection<String> jids) throws XMPPException.XMPPErrorException, SmackException.NoResponseException, SmackException.NotConnectedException
jids
- the bare XMPP user IDs of the user to revoke administrator privileges.XMPPException.XMPPErrorException
- if an error occurs revoking administrator privileges from a user.SmackException.NoResponseException
- if there was no response from the server.SmackException.NotConnectedException
public void revokeAdmin(String jid) throws XMPPException.XMPPErrorException, SmackException.NoResponseException, SmackException.NotConnectedException
jid
- the bare XMPP user ID of the user to revoke administrator privileges
(e.g. "user@host.org").XMPPException.XMPPErrorException
- if an error occurs revoking administrator privileges from a user.SmackException.NoResponseException
- if there was no response from the server.SmackException.NotConnectedException
public int getOccupantsCount()
Note: this value will only be accurate after joining the group chat, and may fluctuate over time. If you query this value directly after joining the group chat it may not be accurate, as it takes a certain amount of time for the server to send all presence packets to this client.
public List<String> getOccupants()
StringUtils.parseResource(String)
method.
Note: this value will only be accurate after joining the group chat, and may
fluctuate over time.public Presence getOccupantPresence(String user)
user
- the room occupant to search for his presence. The format of user must
be: roomName@service/nickname (e.g. darkcave@macbeth.shakespeare.lit/thirdwitch).public Occupant getOccupant(String user)
user
- the room occupant to search for his presence. The format of user must
be: roomName@service/nickname (e.g. darkcave@macbeth.shakespeare.lit/thirdwitch).public void addParticipantListener(PacketListener listener)
listener
- a packet listener that will be notified of any presence packets
sent to the group chat.public void removeParticipantListener(PacketListener listener)
listener
- a packet listener that was being notified of any presence packets
sent to the group chat.public Collection<Affiliate> getOwners() throws SmackException.NoResponseException, XMPPException.XMPPErrorException, SmackException.NotConnectedException
Affiliate
with the room owners.Affiliate
with the room owners.XMPPException.XMPPErrorException
- if you don't have enough privileges to get this information.SmackException.NoResponseException
- if there was no response from the server.SmackException.NotConnectedException
public Collection<Affiliate> getAdmins() throws SmackException.NoResponseException, XMPPException.XMPPErrorException, SmackException.NotConnectedException
Affiliate
with the room administrators.Affiliate
with the room administrators.XMPPException.XMPPErrorException
- if you don't have enough privileges to get this information.SmackException.NoResponseException
- if there was no response from the server.SmackException.NotConnectedException
public Collection<Affiliate> getMembers() throws SmackException.NoResponseException, XMPPException.XMPPErrorException, SmackException.NotConnectedException
Affiliate
with the room members.Affiliate
with the room members.XMPPException.XMPPErrorException
- if you don't have enough privileges to get this information.SmackException.NoResponseException
- if there was no response from the server.SmackException.NotConnectedException
public Collection<Affiliate> getOutcasts() throws SmackException.NoResponseException, XMPPException.XMPPErrorException, SmackException.NotConnectedException
Affiliate
with the room outcasts.Affiliate
with the room outcasts.XMPPException.XMPPErrorException
- if you don't have enough privileges to get this information.SmackException.NoResponseException
- if there was no response from the server.SmackException.NotConnectedException
public Collection<Occupant> getModerators() throws SmackException.NoResponseException, XMPPException.XMPPErrorException, SmackException.NotConnectedException
Occupant
with the room moderators.Occupant
with the room moderators.XMPPException.XMPPErrorException
- if you don't have enough privileges to get this information.SmackException.NoResponseException
- if there was no response from the server.SmackException.NotConnectedException
public Collection<Occupant> getParticipants() throws SmackException.NoResponseException, XMPPException.XMPPErrorException, SmackException.NotConnectedException
Occupant
with the room participants.Occupant
with the room participants.XMPPException.XMPPErrorException
- if you don't have enough privileges to get this information.SmackException.NoResponseException
- if there was no response from the server.SmackException.NotConnectedException
public void sendMessage(String text) throws XMPPException, SmackException.NotConnectedException
text
- the text of the message to send.XMPPException
- if sending the message fails.SmackException.NotConnectedException
public Chat createPrivateChat(String occupant, MessageListener listener)
occupant
- occupant unique room JID (e.g. 'darkcave@macbeth.shakespeare.lit/Paul').listener
- the listener is a message listener that will handle messages for the newly
created chat.public Message createMessage()
public void sendMessage(Message message) throws XMPPException, SmackException.NotConnectedException
message
- the message.XMPPException
- if sending the message fails.SmackException.NotConnectedException
public Message pollMessage()
nextMessage()
method since it's non-blocking.
In other words, the method call will always return immediately, whereas the
nextMessage method will return only when a message is available (or after
a specific timeout).public Message nextMessage()
public Message nextMessage(long timeout)
timeout
- the maximum amount of time to wait for the next message.public void addMessageListener(PacketListener listener)
listener
- a packet listener.public void removeMessageListener(PacketListener listener)
listener
- a packet listener.public void changeSubject(String subject) throws SmackException.NoResponseException, XMPPException.XMPPErrorException, SmackException.NotConnectedException
subject
- the new room's subject to set.XMPPException.XMPPErrorException
- if someone without appropriate privileges attempts to change the
room subject will throw an error with code 403 (i.e. Forbidden)SmackException.NoResponseException
- if there was no response from the server.SmackException.NotConnectedException
public void addUserStatusListener(UserStatusListener listener)
listener
- a user status listener.public void removeUserStatusListener(UserStatusListener listener)
listener
- a user status listener.public void addParticipantStatusListener(ParticipantStatusListener listener)
listener
- a participant status listener.public void removeParticipantStatusListener(ParticipantStatusListener listener)
listener
- a participant status listener.