public class ChatManager extends AbstractPacketForwarder implements PacketCollector
ChatManager manages user conversations. ChatManager uses
XMPPStreamManager to manage xmpp stream with remote server. It
is important to note that a XMPPStreamManager can manage a single
stream at a time.
There is no synchronous interface available for ChatManager as
messaging services are inherently asynchronous.
| Constructor and Description |
|---|
ChatManager(XMPPStreamManager streamManager) |
| Modifier and Type | Method and Description |
|---|---|
void |
collect(Packet packet)
This collector takes the given packet.
|
FileTransferFuture |
downloadFile(JID from,
String fileId,
ContentType contentType)
Download a file for which a
Message with media content has been
received. |
void |
downloadFile(JID from,
String fileId,
ContentType contentType,
Callback<File,FileTransfer.FailureReason> callback)
Download a file for which a
Message with media content has been
received. |
void |
enableFileTransfer(FileInstanceSupplier fileSupplier)
By default, file transfer is not enabled for a chat conversation.
|
void |
enableFileTransfer(InboundFileTransferFilter filter,
FileInstanceSupplier fileSupplier)
By default, file transfer is not enabled for a chat conversation.
|
boolean |
say(String messageId,
String text,
JID to)
Convenience method to send a text message to a
JID. |
boolean |
say(String messageId,
String text,
JID to,
boolean isGroup)
A
Message packet is created with the given text and sent to
XMPPStreamManager which writes it on the underlying connection. |
boolean |
say(String messageId,
String text,
JID to,
boolean isGroup,
boolean isMarkable)
A
Message packet is created with the given text and sent to
XMPPStreamManager which writes it on the underlying connection. |
boolean |
say(String conversationId,
String messageId,
String text,
JID to,
boolean isGroup,
boolean isMarkable)
A
Message packet is created with the given text and sent to
XMPPStreamManager which writes it on the underlying connection. |
boolean |
send(Message msg)
Write
Message packet on to wire using XMPPStreamManager |
boolean |
sendComposingCSN(JID to)
Sending COMPOSING chat state notification explained in XEP-0085(Chat
State Notifications)
|
boolean |
sendGoneCSN(JID to)
Sending GONE chat state notification explained in XEP-0085(Chat State
Notifications)
|
boolean |
sendInactiveCSN(JID to)
Sending INACTIVE chat state notification explained in XEP-0085(Chat State
Notifications)
|
boolean |
sendMarkableMessage(String messageId,
String text,
JID to,
boolean isGroup)
A
Message packet is created with the given text and sent to
XMPPStreamManager which writes it on the underlying connection. |
boolean |
sendMarkableMessage(String conversationId,
String messageId,
String text,
JID to,
boolean isGroup)
A
Message packet is created with the given text and sent to
XMPPStreamManager which writes it on the underlying connection. |
boolean |
sendMarkableMessageWithCSN(String messageId,
String text,
JID to,
boolean isGroup)
A
Message packet is created with the given text and sent to
XMPPStreamManager which writes it on the underlying connection. |
boolean |
sendMarkableMessageWithCSN(String conversationId,
String messageId,
String text,
JID to,
boolean isGroup)
A
Message packet is created with the given text and sent to
XMPPStreamManager which writes it on the underlying connection. |
boolean |
sendMediaMessage(String conversationId,
String messageId,
ContentType contentType,
String mediaThumb,
JID toJID,
boolean isGroup,
boolean isMarkable,
boolean isMDRSupported,
boolean isCSNSupported)
A
Message packet is created with the given mediaId and sent to
XMPPStreamManager which writes it on the underlying connection. |
boolean |
sendMsgCMAcknowledgedReceipt(String messageId,
JID to,
boolean isGroup)
Sending message acknowledged receipt to sender explained in XEP-0333(Chat
Markers)
|
boolean |
sendMsgCMDisplayedReceipt(String messageId,
JID to,
boolean isGroup)
Sending message displayed receipt to sender explained in XEP-0333(Chat
Markers)
|
boolean |
sendMsgCMReceivedReceipt(String messageId,
JID to,
boolean isGroup)
Sending message received receipt to sender explained in XEP-0333(Chat
Markers)
|
boolean |
sendMsgMDRReceivedReceipt(String messageId,
JID to,
boolean isGroup)
Sending message received receipt to sender explained in XEP-0184(Message
Deliver receipt)
|
boolean |
sendPausedCSN(JID to)
Sending PAUSED chat state notification explained in XEP-0085(Chat State
Notifications)
|
boolean |
sendTextMessage(String conversationId,
String messageId,
String text,
JID to,
boolean isGroup,
boolean isMarkable,
boolean isMDRSupported,
boolean isCSNSupported)
Send a message
|
void |
uploadFile(String mediaId,
File file,
ContentType contentType,
JID to,
Callback<String,FileTransfer.FailureReason> callback)
Upload a file on to server
|
addPacketCollector, addPacketCollector, forwardDefault, forwardPacket, removePacketCollector, removePacketCollectorpublic ChatManager(XMPPStreamManager streamManager)
public void enableFileTransfer(FileInstanceSupplier fileSupplier) throws InitializationErrorException
FileTransferDisabledException will be thrown; and if a file is
received when file transfer is disbled for SDK, the file received request
will be ignored silently.
As part of FileTransfer processing, FileTransferManager
writes file on to the disk. In order to write the file, a File
instance is required which is injected through
FileInstanceSupplier
fileSupplier - FileInstanceSupplier implementation to supply
File instanceInitializationErrorException - if the FileTransferManager
Initialisation failspublic void enableFileTransfer(InboundFileTransferFilter filter, FileInstanceSupplier fileSupplier) throws InitializationErrorException
FileTransferDisabledException will be thrown; and if a file is
received when file transfer is disbled for SDK, the file received request
will be ignored silently.
As part of FileTransfer processing, FileTransferManager
writes file on to the disk. In order to write the file, a File
instance is required which is injected through
FileInstanceSupplier
filter - InboundFileTransferFilter implementation which is
used to accept/reject FileTransfersfileSupplier - FileInstanceSupplier implementation to supply
File instanceInitializationErrorException - if the FileTransferManager
initialization failspublic void downloadFile(JID from, String fileId, ContentType contentType, Callback<File,FileTransfer.FailureReason> callback)
Message with media content has been
received.public FileTransferFuture downloadFile(JID from, String fileId, ContentType contentType)
Message with media content has been
received.from - JID of the senderfileId - unique id of the file; this is received in MessagecontentType - content type of the file; received in MessageFileTransferFuturepublic void uploadFile(String mediaId, File file, ContentType contentType, JID to, Callback<String,FileTransfer.FailureReason> callback)
mediaId - Id for media messagefile - File object of mediacontentType - ContentType of media fileto - JID of media message receivercallback - callback to know file transfer statuspublic boolean say(String messageId, String text, JID to)
JID. A
Message packet is created with the given text and sent to
XMPPStreamManager which writes it on the underlying connection.messageId - unique id of the messagetext - raw text to be sent to server within a message packetto - receiver JIDpublic boolean say(String messageId, String text, JID to, boolean isGroup)
Message packet is created with the given text and sent to
XMPPStreamManager which writes it on the underlying connection. A
true value for flag 'isGroup' indicates that messages is intended to be
sent to a group.messageId - uniqueId of the message packettext - raw text to be sent to server within a message packetto - receiver JIDisGroup - true if messages being sent to a group' otherwise falsepublic boolean say(String messageId, String text, JID to, boolean isGroup, boolean isMarkable)
Message packet is created with the given text and sent to
XMPPStreamManager which writes it on the underlying connection. A
true value for flag 'isGroup' indicates that messages is intended to be
sent to a group. And a true value for flag 'isMarkable' indicates that
this message is intended to get delivery and read receipt according to
XEP-0333(Chat-Markers).messageId - uniqueId of the message packettext - raw text to be sent to server within a message packetto - receiver JIDisGroup - true if messages being sent to a group otherwise falseisMarkable - true for getting delivery and read receiptpublic boolean say(String conversationId, String messageId, String text, JID to, boolean isGroup, boolean isMarkable)
Message packet is created with the given text and sent to
XMPPStreamManager which writes it on the underlying connection. A
true value for flag 'isGroup' indicates that messages is intended to be
sent to a group. And a true value for flag 'isMarkable' indicates that
this message is intended to get delivery and read receipt according to
XEP-0333(Chat-Markers).conversationId - conversationIdmessageId - uniqueId of the message packettext - raw text to be sent to server within a message packetto - receiver JIDisGroup - true if messages being sent to a group otherwise falseisMarkable - true for getting delivery and read receipt.public boolean sendMarkableMessage(String messageId, String text, JID to, boolean isGroup)
Message packet is created with the given text and sent to
XMPPStreamManager which writes it on the underlying connection. A
true value for flag 'isGroup' indicates that messages is intended to be
sent to a group.And this * message is intended to get delivery and read
receipt according to XEP-0333(Chat-Markers).messageId - uniqueId of the message packettext - raw text to be sent to server within a message packetto - receiver JIDisGroup - true if messages being sent to a group' otherwise falsepublic boolean sendMarkableMessage(String conversationId, String messageId, String text, JID to, boolean isGroup)
Message packet is created with the given text and sent to
XMPPStreamManager which writes it on the underlying connection. A
true value for flag 'isGroup' indicates that messages is intended to be
sent to a group.And this * message is intended to get delivery and read
receipt according to XEP-0333(Chat-Markers).conversationId - uniqueId for conversationmessageId - uniqueId of the message packettext - raw text to be sent to server within a message packetto - receiver JIDisGroup - true if messages being sent to a group' otherwise falsepublic boolean sendMarkableMessageWithCSN(String messageId, String text, JID to, boolean isGroup)
Message packet is created with the given text and sent to
XMPPStreamManager which writes it on the underlying connection. A
true value for flag 'isGroup' indicates that messages is intended to be
sent to a group.And this * message is intended to get delivery and read
receipt according to XEP-0333(Chat-Markers).messageId - uniqueId of the messagetext - raw text to be sent to server within a message packetto - receiver JIDisGroup - true if messages being sent to a group' otherwise falsepublic boolean sendMarkableMessageWithCSN(String conversationId, String messageId, String text, JID to, boolean isGroup)
Message packet is created with the given text and sent to
XMPPStreamManager which writes it on the underlying connection. A
true value for flag 'isGroup' indicates that messages is intended to be
sent to a group.And this * message is intended to get delivery and read
receipt according to XEP-0333(Chat-Markers).conversationId - conversationIdmessageId - uniqueId of the messagetext - raw text to be sent to server within a message packetto - receiver JIDisGroup - true if messages being sent to a group' otherwise falsepublic boolean sendMediaMessage(String conversationId, String messageId, ContentType contentType, String mediaThumb, JID toJID, boolean isGroup, boolean isMarkable, boolean isMDRSupported, boolean isCSNSupported)
Message packet is created with the given mediaId and sent to
XMPPStreamManager which writes it on the underlying connection. A
true value for flag 'isGroup' indicates that messages is intended to be
sent to a group.conversationId - conversationIdmessageId - messageIdcontentType - contentType of the file being sentmediaThumb - Base64 encoded media thumbtoJID - receiver JIDisGroup - true if messages being sent to a group' otherwise falseisMarkable - is Need Chat Markers (XEP-0333)isMDRSupported - isMDRSupportedisCSNSupported - isCSNSupportedpublic boolean sendTextMessage(String conversationId, String messageId, String text, JID to, boolean isGroup, boolean isMarkable, boolean isMDRSupported, boolean isCSNSupported)
conversationId - conversationIdmessageId - messageIdtext - message textto - receiver JIDisGroup - true if the message is sent to a groupisMarkable - is Need Chat Markers (XEP-0333)isMDRSupported - isMDRSupportedisCSNSupported - is support Chat State Notification (XEP-0085)public boolean sendMsgMDRReceivedReceipt(String messageId, JID to, boolean isGroup)
messageId - received message idto - message sender JIDisGroup - isGroup flagpublic boolean sendMsgCMReceivedReceipt(String messageId, JID to, boolean isGroup)
messageId - received message idto - message sender JIDisGroup - isGrouppublic boolean sendMsgCMDisplayedReceipt(String messageId, JID to, boolean isGroup)
messageId - received message idto - message sender JIDisGroup - isGrouppublic boolean sendMsgCMAcknowledgedReceipt(String messageId, JID to, boolean isGroup)
messageId - received message idto - message sender JIDisGroup - isGroup flagpublic boolean sendInactiveCSN(JID to)
to - contact JIDpublic boolean sendComposingCSN(JID to)
to - contact JIDpublic boolean sendPausedCSN(JID to)
to - contact JIDpublic boolean sendGoneCSN(JID to)
to - contact JIDpublic boolean send(Message msg)
Message packet on to wire using XMPPStreamManagermsg - outbound Message packetpublic void collect(Packet packet)
PacketCollectorcollect in interface PacketCollectorpacket - packet instance to be collectedCopyright © 2019. All rights reserved.