public final class ChatRoom extends Chat implements java.lang.Comparable<ChatRoom>
Represents a multi-user chat room.
Use this class to enter a chat room, to send and receive messages, invite others and to manage members (e.g. kick or ban a user, grant admin status, etc.).
Modifier and Type | Method and Description |
---|---|
void |
addInvitationDeclineListener(java.util.function.Consumer<InvitationDeclineEvent> invitationDeclineListener)
Adds a invitation decline listener, which allows to listen for invitation declines.
|
void |
addOccupantListener(java.util.function.Consumer<OccupantEvent> occupantListener)
Adds an occupant listener, which allows to listen for presence changes of occupants, e.g.
|
void |
addSubjectChangeListener(java.util.function.Consumer<SubjectChangeEvent> subjectChangeListener)
Adds a subject change listener, which allows to listen for subject changes.
|
AsyncResult<IQ> |
banUser(Jid user,
java.lang.String reason)
Bans a user.
|
AsyncResult<IQ> |
changeAffiliation(Affiliation affiliation,
Jid user,
java.lang.String reason)
Changes the affiliation for an user.
|
AsyncResult<IQ> |
changeAffiliationsOrRoles(java.util.List<Item> items)
Changes multiple affiliations or roles.
|
void |
changeAvailabilityStatus(Presence.Show show,
java.lang.String status)
Changes the availability status.
|
AsyncResult<Presence> |
changeNickname(java.lang.String newNickname)
Changes the nickname.
|
AsyncResult<IQ> |
changeRole(Role role,
java.lang.String nickname,
java.lang.String reason)
Changes the role for an occupant.
|
AsyncResult<Message> |
changeSubject(java.lang.String subject)
Changes the room subject.
|
int |
compareTo(ChatRoom o)
Compares this chat service first by their name and then by their service address.
|
AsyncResult<IQ> |
configure(RoomConfiguration roomConfiguration)
Configures this room.
|
AsyncResult<IQ> |
destroy()
Destroys the room.
|
AsyncResult<IQ> |
destroy(java.lang.String reason)
Destroys the room.
|
AsyncResult<java.util.Set<java.lang.String>> |
discoverAllowableTraffic()
Discovers the allowable traffic, i.e. the allowed extensions.
|
AsyncResult<java.util.List<java.lang.String>> |
discoverOccupants()
Gets the occupants in this room, i.e. their nicknames.
|
AsyncResult<java.lang.String> |
discoverReservedNickname()
Gets your reserved room nickname.
|
AsyncResult<Presence> |
enter(java.lang.String nick)
Enters the room.
|
AsyncResult<Presence> |
enter(java.lang.String nick,
DiscussionHistory history)
Enters the room and requests history messages.
|
AsyncResult<Presence> |
enter(java.lang.String nick,
java.lang.String password)
Enters the room with a password.
|
AsyncResult<Presence> |
enter(java.lang.String nick,
java.lang.String password,
DiscussionHistory history)
Enters the room with a password and requests history messages.
|
AsyncResult<java.lang.Void> |
exit()
Exits the room.
|
AsyncResult<java.lang.Void> |
exit(java.lang.String message)
Exits the room with a custom message.
|
Jid |
getAddress()
Gets the room address.
|
AsyncResult<java.util.List<Item>> |
getAdmins()
Gets the admins of the room.
|
AsyncResult<java.util.List<Item>> |
getBanList()
Gets the ban list.
|
AsyncResult<DataForm> |
getConfigurationForm()
Gets the configuration form for the room.
|
AsyncResult<java.util.List<Item>> |
getMembers()
Gets the members of the room.
|
AsyncResult<java.util.List<Item>> |
getModerators()
Gets the moderators.
|
java.lang.String |
getName()
Gets the name for this room.
|
java.lang.String |
getNick()
Gets the nickname in this room.
|
Occupant |
getOccupant(java.lang.String nickname)
Gets an occupant by nickname.
|
java.util.Collection<Occupant> |
getOccupants()
Gets the occupants, while being in the room.
|
AsyncResult<java.util.List<Item>> |
getOutcasts()
Gets the outcasts of the room.
|
AsyncResult<java.util.List<Item>> |
getOwners()
Gets the owners of the room.
|
AsyncResult<DataForm> |
getRegistrationForm()
Gets the data form necessary to register with the room.
|
AsyncResult<RoomInformation> |
getRoomInformation()
Gets the room information for this chat room.
|
AsyncResult<java.util.List<Item>> |
getVoiceList()
Gets the voice list.
|
AsyncResult<IQ> |
grantAdminStatus(Jid user,
java.lang.String reason)
Grants admin status to a user.
|
AsyncResult<IQ> |
grantMembership(Jid user,
java.lang.String nick,
java.lang.String reason)
Grants membership to a user.
|
AsyncResult<IQ> |
grantModeratorStatus(java.lang.String nickname,
java.lang.String reason)
Grants moderator status to a participant or visitor.
|
AsyncResult<IQ> |
grantOwnerStatus(Jid user,
java.lang.String reason)
Grants owner status to a user.
|
AsyncResult<IQ> |
grantVoice(java.lang.String nickname,
java.lang.String reason)
Grants voice to a visitor.
|
boolean |
hasEntered()
Indicates, if you have entered the room.
|
void |
invite(Jid invitee,
java.lang.String reason)
Invites another user to the room.
|
void |
invite(Jid invitee,
java.lang.String reason,
boolean direct)
Invites another user to the room.
|
AsyncResult<IQ> |
kickOccupant(java.lang.String nickname,
java.lang.String reason)
Kicks an occupant from the room.
|
AsyncResult<IQ> |
register(Registration registration)
Registers with the room.
|
void |
removeInvitationDeclineListener(java.util.function.Consumer<InvitationDeclineEvent> invitationDeclineListener)
Removes a previously added invitation decline listener.
|
void |
removeOccupantListener(java.util.function.Consumer<OccupantEvent> occupantListener)
Removes a previously added occupant listener.
|
void |
removeSubjectChangeListener(java.util.function.Consumer<SubjectChangeEvent> subjectChangeListener)
Removes a previously added subject change listener.
|
void |
requestVoice()
Requests voice in a moderated room.
|
AsyncResult<IQ> |
revokeAdminStatus(Jid user,
java.lang.String reason)
Revokes a user’s admin status.
|
AsyncResult<IQ> |
revokeMembership(Jid user,
java.lang.String reason)
Revokes a user’s membership.
|
AsyncResult<IQ> |
revokeModeratorStatus(java.lang.String nickname,
java.lang.String reason)
Revokes moderator status from a participant or visitor.
|
AsyncResult<IQ> |
revokeOwnerStatus(Jid user,
java.lang.String reason)
Revokes a user’s owner status.
|
AsyncResult<IQ> |
revokeVoice(java.lang.String nickname,
java.lang.String reason)
Revokes voice from a participant.
|
SendTask<Message> |
sendMessage(Message message)
Sends a message to the room.
|
SendTask<Message> |
sendMessage(java.lang.String message)
Sends a message to the room.
|
java.lang.String |
toString() |
addInboundMessageListener, removeInboundMessageListener
public void addInvitationDeclineListener(java.util.function.Consumer<InvitationDeclineEvent> invitationDeclineListener)
Adds a invitation decline listener, which allows to listen for invitation declines.
invitationDeclineListener
- The listener.removeInvitationDeclineListener(Consumer)
public void removeInvitationDeclineListener(java.util.function.Consumer<InvitationDeclineEvent> invitationDeclineListener)
Removes a previously added invitation decline listener.
invitationDeclineListener
- The listener.addInvitationDeclineListener(Consumer)
public void addSubjectChangeListener(java.util.function.Consumer<SubjectChangeEvent> subjectChangeListener)
Adds a subject change listener, which allows to listen for subject changes.
subjectChangeListener
- The listener.removeSubjectChangeListener(Consumer)
public void removeSubjectChangeListener(java.util.function.Consumer<SubjectChangeEvent> subjectChangeListener)
Removes a previously added subject change listener.
subjectChangeListener
- The listener.addSubjectChangeListener(Consumer)
public void addOccupantListener(java.util.function.Consumer<OccupantEvent> occupantListener)
Adds an occupant listener, which allows to listen for presence changes of occupants, e.g. “joins” and “leaves”.
occupantListener
- The listener.removeOccupantListener(Consumer)
public void removeOccupantListener(java.util.function.Consumer<OccupantEvent> occupantListener)
Removes a previously added occupant listener.
occupantListener
- The listener.addOccupantListener(Consumer)
public AsyncResult<Presence> enter(java.lang.String nick)
Enters the room.
nick
- The nickname.public AsyncResult<Presence> enter(java.lang.String nick, java.lang.String password)
Enters the room with a password.
nick
- The nickname.password
- The password.public AsyncResult<Presence> enter(java.lang.String nick, DiscussionHistory history)
Enters the room and requests history messages.
nick
- The nickname.history
- The history.public final AsyncResult<Presence> enter(java.lang.String nick, java.lang.String password, DiscussionHistory history)
Enters the room with a password and requests history messages.
nick
- The nickname.password
- The password.history
- The history.public AsyncResult<Message> changeSubject(java.lang.String subject)
Changes the room subject.
subject
- The subject.public SendTask<Message> sendMessage(java.lang.String message)
Sends a message to the room.
sendMessage
in class Chat
message
- The message text.public SendTask<Message> sendMessage(Message message)
Sends a message to the room.
sendMessage
in class Chat
message
- The message.public final AsyncResult<Presence> changeNickname(java.lang.String newNickname)
Changes the nickname.
newNickname
- The new nickname.public void changeAvailabilityStatus(Presence.Show show, java.lang.String status)
Changes the availability status.
show
- The ‘show’ value.status
- The status.public void invite(Jid invitee, java.lang.String reason)
Invites another user to the room. The invitation will be mediated by the room.
invitee
- The invitee.reason
- The reason.public void invite(Jid invitee, java.lang.String reason, boolean direct)
Invites another user to the room. The invitation will be either mediated by the room or direct.
invitee
- The invitee.reason
- The reason.direct
- True, if the message is sent directly to the invitee; false if it is mediated by the room.public AsyncResult<DataForm> getRegistrationForm()
Gets the data form necessary to register with the room.
RoomRegistration
public AsyncResult<IQ> register(Registration registration)
Registers with the room.
registration
- The registration.RoomRegistration
public AsyncResult<java.lang.String> discoverReservedNickname()
Gets your reserved room nickname.
public void requestVoice()
Requests voice in a moderated room.
public AsyncResult<java.lang.Void> exit()
Exits the room.
public final AsyncResult<java.lang.Void> exit(java.lang.String message)
Exits the room with a custom message.
message
- The exit message.public final boolean hasEntered()
Indicates, if you have entered the room. When you exit the room, this method returns false.
enter(String)
,
exit()
public AsyncResult<java.util.List<Item>> getVoiceList()
Gets the voice list.
public AsyncResult<IQ> changeAffiliationsOrRoles(java.util.List<Item> items)
Changes multiple affiliations or roles.
items
- The items.public AsyncResult<java.util.List<Item>> getBanList()
Gets the ban list.
public final AsyncResult<IQ> changeAffiliation(Affiliation affiliation, Jid user, java.lang.String reason)
Changes the affiliation for an user.
Use this method for one of the following use cases:
Affiliation.OUTCAST
)Affiliation.MEMBER
)Affiliation.NONE
)Affiliation.ADMIN
)Affiliation.MEMBER
)Affiliation.OWNER
)Affiliation.ADMIN
)affiliation
- The new affiliation for the user.user
- The user.reason
- The reason.public final AsyncResult<IQ> banUser(Jid user, java.lang.String reason)
Bans a user. Note that you must be an owner or admin of the room.
user
- The user.reason
- The reason (optional). May be null
.public final AsyncResult<IQ> grantMembership(Jid user, java.lang.String nick, java.lang.String reason)
Grants membership to a user. Note that you must be an owner or admin of the room.
user
- The user.nick
- The nick (optional). That nick becomes the user’s default nick in the room if that functionality is supported by the implementation. May be null
.reason
- The reason (optional). May be null
.revokeMembership(Jid, String)
public final AsyncResult<IQ> revokeMembership(Jid user, java.lang.String reason)
Revokes a user’s membership. Note that you must be an owner or admin of the room.
user
- The user.reason
- The reason (optional). May be null
.grantMembership(Jid, String, String)
public final AsyncResult<IQ> grantOwnerStatus(Jid user, java.lang.String reason)
Grants owner status to a user. Note that you must be an owner of the room.
user
- The user.reason
- The reason (optional). May be null
.revokeOwnerStatus(Jid, String)
public final AsyncResult<IQ> revokeOwnerStatus(Jid user, java.lang.String reason)
Revokes a user’s owner status. The new status of the user will be ‘admin’. Note that you must be an owner of the room. This method does basically the same as grantAdminStatus(Jid, String)
}.
user
- The user.reason
- The reason (optional). May be null
.grantOwnerStatus(Jid, String)
public final AsyncResult<IQ> grantAdminStatus(Jid user, java.lang.String reason)
Grants admin status to a user. Note that you must be an owner of the room. This method does basically the same as revokeOwnerStatus(Jid, String)
.
user
- The user.reason
- The reason (optional). May be null
.revokeAdminStatus(Jid, String)
public final AsyncResult<IQ> revokeAdminStatus(Jid user, java.lang.String reason)
Revokes a user’s admin status. The new status of the user will be ‘member’. Note that you must be an owner of the room.
user
- The user.reason
- The reason (optional). May be null
.grantAdminStatus(Jid, String)
public final AsyncResult<IQ> changeRole(Role role, java.lang.String nickname, java.lang.String reason)
Changes the role for an occupant.
Use this method for one of the following use cases:
Role.NONE
)Role.PARTICIPANT
)Role.VISITOR
)Role.MODERATOR
)Role.PARTICIPANT
)role
- The new role for the user.nickname
- The occupant’s nickname.reason
- The reason.public final AsyncResult<IQ> kickOccupant(java.lang.String nickname, java.lang.String reason)
Kicks an occupant from the room. Note that you must be a moderator in the room.
nickname
- The nickname.reason
- The reason (optional). May be null
.public final AsyncResult<IQ> grantVoice(java.lang.String nickname, java.lang.String reason)
Grants voice to a visitor. Note that you must be a moderator in the room. This method does basically the same as revokeModeratorStatus(String, String)
}}.
nickname
- The nickname.reason
- The reason (optional). May be null
.revokeVoice(String, String)
public final AsyncResult<IQ> revokeVoice(java.lang.String nickname, java.lang.String reason)
Revokes voice from a participant. Note that you must be a moderator in the room.
nickname
- The nickname.reason
- The reason (optional). May be null
.grantVoice(String, String)
public final AsyncResult<IQ> grantModeratorStatus(java.lang.String nickname, java.lang.String reason)
Grants moderator status to a participant or visitor. Note that you must be an admin in the room.
nickname
- The nickname.reason
- The reason (optional). May be null
.public final AsyncResult<IQ> revokeModeratorStatus(java.lang.String nickname, java.lang.String reason)
Revokes moderator status from a participant or visitor. Note that you must be an admin in the room. This method does basically the same as grantVoice(String, String)
.
nickname
- The nickname.reason
- The reason (optional). May be null
.public AsyncResult<java.util.List<Item>> getOwners()
Gets the owners of the room.
public AsyncResult<java.util.List<Item>> getOutcasts()
Gets the outcasts of the room.
public AsyncResult<java.util.List<Item>> getAdmins()
Gets the admins of the room.
public AsyncResult<java.util.List<Item>> getMembers()
Gets the members of the room.
In the context of a members-only room, the member list is essentially a “whitelist” of people who are allowed to enter the room.
In the context of an open room, the member list is simply a list of users (bare JID and reserved nick) who are registered with the room.
public AsyncResult<java.util.List<Item>> getModerators()
Gets the moderators.
public AsyncResult<RoomInformation> getRoomInformation()
Gets the room information for this chat room.
public AsyncResult<java.util.List<java.lang.String>> discoverOccupants()
Gets the occupants in this room, i.e. their nicknames. This method should be used, when you are not yet in the room.
getOccupants()
public java.util.Collection<Occupant> getOccupants()
Gets the occupants, while being in the room.
public Occupant getOccupant(java.lang.String nickname)
Gets an occupant by nickname.
nickname
- The occupant’s nickname.public AsyncResult<DataForm> getConfigurationForm()
Gets the configuration form for the room. You can wrap the form into RoomConfiguration
for easier processing.
Use this method if you want to create a reserved room or configure an existing room.
RoomConfiguration
,
10.1.3 Creating a Reserved Room,
configure(RoomConfiguration)
public AsyncResult<IQ> configure(RoomConfiguration roomConfiguration)
Configures this room.
roomConfiguration
- The async result with the room configuration form.getConfigurationForm()
public final java.lang.String getName()
Gets the name for this room.
public final java.lang.String getNick()
Gets the nickname in this room. Usually this is the nick used to enter the room, but can also be a nickname assigned by the chat service.
null
, if not entered.public AsyncResult<IQ> destroy(java.lang.String reason)
Destroys the room.
reason
- The reason for the room destruction.public final AsyncResult<IQ> destroy()
Destroys the room.
public Jid getAddress()
Gets the room address.
public AsyncResult<java.util.Set<java.lang.String>> discoverAllowableTraffic()
Discovers the allowable traffic, i.e. the allowed extensions.
public java.lang.String toString()
toString
in class java.lang.Object
Copyright © 2014–2019 XMPP.rocks. All rights reserved.