Package rocks.xmpp.extensions.blocking
Class BlockingManager
- java.lang.Object
-
- rocks.xmpp.core.stanza.AbstractIQHandler
-
- rocks.xmpp.extensions.blocking.BlockingManager
-
- All Implemented Interfaces:
ExtensionProtocol
,IQHandler
,DiscoverableInfo
public final class BlockingManager extends AbstractIQHandler implements ExtensionProtocol, DiscoverableInfo
This manager allows to block communications with contacts.Usage
Listen for pushes from the server which informs you about changes in the block list:
blockingManager.addBlockingListener(e -> { // e.getBlockedContacts(); // modify the block list accordingly. });
After authenticating with a server and before any blocking operation you should retrieve the block list:
blockingManager.getBlockedContacts();
This will also inform the server that you are interested in updates to the list and will trigger pushes to the client.
This class is thread-safe.
-
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
addBlockingListener(Consumer<BlockingEvent> blockingListener)
Adds a blocking listener, which allows to listen for block and unblock pushes.AsyncResult<IQ>
blockContact(Jid... jids)
Blocks communications with contacts.AsyncResult<Set<Jid>>
getBlockedContacts()
Retrieves the blocked contacts.Set<String>
getFeatures()
Gets the features.String
getNamespace()
The protocol's main namespace.boolean
isEnabled()
Indicates whether this protocol is enabled.void
removeBlockingListener(Consumer<BlockingEvent> blockingListener)
Removes a previously added blocking listener.AsyncResult<IQ>
unblockContact(Jid... jids)
Unblocks communications with specific contacts or with all contacts.-
Methods inherited from class rocks.xmpp.core.stanza.AbstractIQHandler
getPayloadClass, handleRequest
-
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface rocks.xmpp.extensions.disco.model.info.DiscoverableInfo
getExtensions, getIdentities
-
-
-
-
Method Detail
-
addBlockingListener
public final void addBlockingListener(Consumer<BlockingEvent> blockingListener)
Adds a blocking listener, which allows to listen for block and unblock pushes.- Parameters:
blockingListener
- The listener.- See Also:
removeBlockingListener(Consumer)
-
removeBlockingListener
public final void removeBlockingListener(Consumer<BlockingEvent> blockingListener)
Removes a previously added blocking listener.- Parameters:
blockingListener
- The listener.- See Also:
addBlockingListener(Consumer)
-
getBlockedContacts
public final AsyncResult<Set<Jid>> getBlockedContacts()
Retrieves the blocked contacts.- Returns:
- The async result with the block list.
- See Also:
- 3.2 User Retrieves Block List
-
blockContact
public final AsyncResult<IQ> blockContact(Jid... jids)
Blocks communications with contacts.- Parameters:
jids
- The contacts.- Returns:
- The async result.
- See Also:
- 3.3 User Blocks Contact
-
unblockContact
public final AsyncResult<IQ> unblockContact(Jid... jids)
Unblocks communications with specific contacts or with all contacts. If you want to unblock all communications, pass no arguments to this method.- Parameters:
jids
- The contacts.- Returns:
- The async result.
- See Also:
- 3.4 User Unblocks Contact, 3.5 User Unblocks All Contacts
-
getNamespace
public final String getNamespace()
The protocol's main namespace. This is used to uniquely identify the extension protocol.- Specified by:
getNamespace
in interfaceExtensionProtocol
- Returns:
- "urn:xmpp:blocking"
-
isEnabled
public final boolean isEnabled()
Description copied from interface:ExtensionProtocol
Indicates whether this protocol is enabled.- Specified by:
isEnabled
in interfaceExtensionProtocol
- Returns:
- true, if enabled; false if disabled.
-
getFeatures
public final Set<String> getFeatures()
Description copied from interface:DiscoverableInfo
Gets the features.- Specified by:
getFeatures
in interfaceDiscoverableInfo
- Returns:
- The features.
-
-