| java.lang.Object | |
| ↳ | com.nexmo.sdk.conversation.client.Conversation |
A container that you use to manage communications between Members, the conversation history and context.
Users cannot manually create conversation objects, but creating a Conversation via
ConversationClient#newConversation(String, RequestHandlerConversation object.
Every action on a conversation will dispatch a completion callback that contains an updated Conversation object. For ex:
myConversation.sendText("payload", new RequestHandler() {
@Override
public void onSuccess(Event text) {
// Update the application UI here if needed with updated conversation.
}
@Override
public void onError(NexmoAPIError error) {
// Update the application UI here if needed.
}
});
Listen for incoming events messageEvent()
Example usage:
conversation.messageEvent().add(new ResultListener() { @Override public void onSuccess(Event result) { notifyUI("New event from " + result.getMemberById()); } });
Sending a text message to a specific conversation is achieved using
Conversation#sendText(String, RequestHandler
Example usage:
myConversation.sendText("message payload...", new RequestHandler() {
@Override
public void onSuccess(Event event) {
// Update the application UI here if needed.
}
@Override
public void onError(NexmoAPIError error) {
// Update the application UI here if needed.
}
});
Marking an event as seen is achieved using
markAsSeen(RequestHandler)
Example usage:
textEvent.markAsSeen( new RequestHandler() {
@Override
public void onSuccess(SeenReceipt seenReceipt) {
// Update the application UI here if needed.
}
@Override
public void onError(NexmoAPIError error) {
// Update the application UI here if needed.
}
});
Listen for typing indicator events Conversation#typingEvent().add(ResultListener Example usage:
myConversation.typingEvent().add(new ResultListener
| Nested Classes | |||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|
| enum | Conversation.MEDIA_TYPE | ||||||||||
| Protected Constructors | |||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|
| Conversation(String displayName) | |||||||||||
| Conversation(String displayName, String cid) | |||||||||||
| Conversation(String displayName, String cid, String lastEventId) | |||||||||||
| Conversation(String displayName, String cid, Member member) | |||||||||||
| Conversation(String displayName, String cid, Member member, Date creationDate) | |||||||||||
| Conversation(String name, String cid, String lastEventId, Member member) | |||||||||||
| Conversation(String displayName, String cid, String lastEventId, Member member, Date creationDate, List<Member> members) | |||||||||||
| Conversation(String name, String cid, String lastEventId, Date creationDate) | |||||||||||
| Conversation(String displayName, String cid, String lastEventId, Member member, Date creationDate) | |||||||||||
| Conversation(String displayName, String cid, String lastEventId, Member member, Date creationDate, List<Member> members, List<Event> events) | |||||||||||
| Conversation(Conversation conversation) | |||||||||||
| Public Methods | |||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|
| void |
deleteEvent(Event event, RequestHandler<Void> eventDeleteListener)
Delete a message event
| ||||||||||
| EventSource<Receipt<DeliveredReceipt>> |
deliveryEvent()
Register for receiving delivered receipt events.
| ||||||||||
| boolean | equals(Object o) | ||||||||||
| Image |
findImage(String id)
Find an Image message based on event ID, synchronously.
| ||||||||||
| Text |
findText(String id)
Find a Text message based on event ID, synchronously.
| ||||||||||
| static Conversation | fromCursor(Cursor cursor) | ||||||||||
| static Conversation |
fromJson(JSONObject body)
Construct object from the network response.
| ||||||||||
| String |
getConversationId()
The id of this conversation.
| ||||||||||
| Date |
getCreationDate()
Get the creation date of this conversation, synchronously.
| ||||||||||
| String |
getDisplayName()
The name of this conversation.
| ||||||||||
| Event |
getEvent(String event_id)
Get an event based on its ID, synchronously.
| ||||||||||
| List<Event> |
getEvents()
Get the list of events that were lastly retrieved, synchronously.
| ||||||||||
| List<Image> |
getImages()
Get the list of image events only , synchronously.
| ||||||||||
| String |
getLastEventId()
The last event id of this conversation.
| ||||||||||
| Member |
getMemberById(String member_id)
Get a member based on its member ID, synchronously.
| ||||||||||
| Member |
getMemberByName(String member_name)
Get a member based on its username, synchronously.
| ||||||||||
| Member |
getMemberByUser(User user)
Get a member based on its user details, synchronously.
| ||||||||||
| String |
getMemberId()
Get the member ID of the current user in this conversation.
| ||||||||||
| List<Member> |
getMembers()
Get all members that are JOINED/INVITED/LEFT in this conversation, synchronously.
| ||||||||||
| Member |
getSelf()
Get the member object for current user.
| ||||||||||
| List<Text> |
getTexts()
Get the list of text events only , synchronously.
| ||||||||||
| int | hashCode() | ||||||||||
| void |
invite(String username, RequestHandler<Member> inviteSendListener)
Invite a user to a certain conversation.
| ||||||||||
| void |
inviteWithAudio(String userId, String username, boolean muted, boolean isEarmuff, RequestHandler<Member> requestHandler)
Invite a user to an audio conversation, using preset params for muted and earmuff.
| ||||||||||
| void |
join(String username, RequestHandler<Member> requestHandler)
Current
User allows another user to join a Conversation. | ||||||||||
| void |
join(RequestHandler<Member> requestHandler)
Current
User joins a Conversation. | ||||||||||
| void |
leave(RequestHandler<Void> leaveListener)
Leave a conversation the
User has joined, or is invited to. | ||||||||||
| AudioCallManager | media(Conversation.MEDIA_TYPE mediaType) | ||||||||||
| EventSource<Invitation> |
memberInvitedEvent()
Register for receiving member invited events.
| ||||||||||
| EventSource<Member> |
memberJoinedEvent()
Register for receiving member joined events.
| ||||||||||
| EventSource<Member> |
memberLeftEvent()
Register for receiving member left events.
| ||||||||||
| EventSource<Event> |
messageEvent()
Listen for incoming messages from this conversation.
| ||||||||||
| EventSource<Receipt<SeenReceipt>> |
seenEvent()
Register for receiving seen receipt events.
| ||||||||||
| ImageUploader.CancelableCall |
sendImage(String imagePath, RequestHandler<Event> imageSendListener)
Send/Upload an Image event to a conversation.
| ||||||||||
| void |
sendText(String message, RequestHandler<Event> listener)
Send a Text event to a conversation.
| ||||||||||
| void | setAudioRoute(AppRTCAudioManager.AudioDevice audioRoute) | ||||||||||
| void |
startTyping(RequestHandler<Member.TYPING_INDICATOR> listener)
Send a typing indicator {
ON event for the
current member of a conversation. | ||||||||||
| void |
stopTyping(RequestHandler<Member.TYPING_INDICATOR> listener)
Send a typing indicator
OFF event for the
current member of a conversation. | ||||||||||
| String | toString() | ||||||||||
| EventSource<Member> |
typingEvent()
Register for receiving typing indicator events from other members.
| ||||||||||
| void |
update(RequestHandler<Conversation> requestHandler)
Retrieve full conversation information, like members and conversation details.
| ||||||||||
| void |
updateEvents(String startId, String endId, RequestHandler<Conversation> requestHandler)
Retrieve the event history of a
Conversation. | ||||||||||
| Protected Methods | |||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|
| void | setTypingTimeOutLength(long typingTimeOutLength) | ||||||||||
|
[Expand]
Inherited Methods | |||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|
From class
java.lang.Object
| |||||||||||
Delete a message event
| event | The event that needs to be deleted. |
|---|
Register for receiving delivered receipt events.
Find an Image message based on event ID, synchronously.
| id | The event id. |
|---|
Find a Text message based on event ID, synchronously.
| id | The event id. |
|---|
Construct object from the network response.
| body | network response |
|---|
| JSONException | if required fields don't exist |
|---|
The id of this conversation.
Get the creation date of this conversation, synchronously.
The name of this conversation.
Get an event based on its ID, synchronously.
| event_id | The event ID. |
|---|
Get the list of events that were lastly retrieved, synchronously.
Get the list of image events only , synchronously.
The last event id of this conversation.
Get a member based on its member ID, synchronously.
If the member appears to be missing this conversation is out of sync, call
Conversation#update(RequestHandler
| member_id | The auto-generated memberID. |
|---|
Get a member based on its username, synchronously.
If the member appears to be missing this conversation is out of sync, call
Conversation#update(RequestHandler
| member_name | The username. |
|---|
Get a member based on its user details, synchronously.
If the member appears to be missing this conversation is out of sync, call
Conversation#update(RequestHandler
| user | The current user. |
|---|
Get the member ID of the current user in this conversation.
Get all members that are JOINED/INVITED/LEFT in this conversation, synchronously.
Get the member object for current user. Once a user joins or gets invited to a conversation, a Member object will be created with same username and id, and auto-generated member ID.
Note: If current user it not part of this conversation (neither joined or was invited to), then this method will return null.
Get the list of text events only , synchronously.
Invite a user to a certain conversation.
The receiving user can accept an invite join(RequestHandler) or reject an invite
leave(RequestHandler).
| username | The user id or name. |
|---|---|
| inviteSendListener | The completion listener. |
Invite a user to an audio conversation, using preset params for muted and earmuff.
Invite by either userId or username, providing one of this params is mandatory.
The receiving user can accept an invite join(RequestHandler) or reject an invite
leave(RequestHandler).
A user accepting an invite to a conversation with audio enabled will need to manually enable audio after accepting invitation.
| userId | The user id. |
|---|---|
| username | The user name. |
| muted | The user will join as muted or not. |
| isEarmuff | The user will join as earmuff or not. |
| requestHandler | The completion listener. |
Current User allows another user to join a Conversation.
Note: any User that joins a Conversation becomes a Member.
| username | The user id or name to join to a conversation. |
|---|---|
| requestHandler | The handler in charge of dispatching the result. |
Current User joins a Conversation.
Note: any User that joins a Conversation becomes a Member.
The User will always be current user that has successfully logged-in.
| requestHandler | The handler in charge of dispatching the result. |
|---|
Leave a conversation the User has joined, or is invited to.
No ownership is enforced on conversation, so any member may invite or remove others.
| leaveListener | The completion listener in charge of dispatching the result. |
|---|
Register for receiving member invited events. This applies for other members being invited to this conversation.
Register for receiving member joined events.
Register for receiving member left events.
Listen for incoming messages from this conversation. Event types:
enable(AudioCallEventListener)
and disable(RequestHandler). For incoming Image event type, the THUMBNAIL representation will be downloaded automatically.
Register for receiving seen receipt events.
When registering for receipt records, the current member will receive all of them, regardless of whether he was the one sending the associated messages.
Note: None of the receipt records can be un-done.
Send/Upload an Image event to a conversation.
Once the image is uploaded, you will be able to access all 3 representations:
getOriginal()getMedium()getThumbnail() Each ImageRepresentation contains a ImageRepresentation#bitmap
that can be used to update UI
Please note that sending image does not get retried in case an error occurs. It is up to the user to resend the image when convenient.
For listening to incoming/sent events events, register using
messageEvent()
| imagePath | The image location, mandatory. |
|---|---|
| imageSendListener | The completion listener, mandatory. |
Send a Text event to a conversation.
For listening to incoming/sent events events, register using
messageEvent()
| message | The payload. |
|---|---|
| listener | The listener in charge of dispatching the completion result. |
Send a typing indicator {ON event for the
current member of a conversation.
| listener | The listener in charge of dispatching the completion result. |
|---|
Send a typing indicator OFF event for the
current member of a conversation.
| listener | The listener in charge of dispatching the completion result. |
|---|
Register for receiving typing indicator events from other members.
Retrieve full conversation information, like members and conversation details. available information includes:
For retrieving the text/image events use Conversation#updateEvents(String, String, RequestHandler Please bear in mind to refresh the members list on a regular basis to avoid events from 'unknown' members.
For the first time launching the app, the local cache will not present any results.
| requestHandler | The handler in charge of dispatching the result. |
|---|
Retrieve the event history of a Conversation.
available information includes:
getTexts() for text messages.getImages() for image messages.getLastEventId() for assessing when a sync is required.| startId | Optional, the first event id to get. |
|---|---|
| endId | Optional, the last event id to get. |
| requestHandler | The handler in charge of dispatching the result. |