public class NexmoConversation
extends java.lang.Object
Create conversations NexmoClient.newConversation(String, String, NexmoRequestListener)
.
NexmoConversation name can be supplied, but if left empty there will be an auto-generated name assigned to the conversation.
Example usage:
stitchClient.newConversation("My NexmoConversation name", "My NexmoConversation display name", new RequestHandler() { @Override public void onSuccess(NexmoConversation conversation) { // Update the application UI here if needed. } @Override public void onError(NexmoAPIError error) { // Update the application UI here if needed. } });
Add another users to the NexmoConversation with join(String, NexmoRequestListener)
*
Example usage:
myConversation.join("username", new RequestHandler() { @Override public void onSuccess(NexmoMember member) { // Update the application UI here if needed. } @Override public void onError(NexmoAPIError error) { // Update the application UI here if needed. } });
Send text messages to a specific conversation with sendText(String, NexmoRequestListener)
.
Example usage:
myConversation.sendText("message payload...", new RequestHandler<() { @Override public void onSuccess(NexmoEvent event) { // Update the application UI here if needed. } @Override public void onError(NexmoAPIError error) { // Update the application UI here if needed. } });
Listen for incoming message events addMessageEventListener(NexmoMessageEventListener)
Example usage:
conversation.addMessageEventListener().add(new MessageEventListener() { @Override public void onTextEvent(TextEvent text) { // Update the application UI here if needed with new text. } @Override public void onAttachmentEvent(AttachmentEvent attachment) { // Update the application UI here if needed with new attachment. } @Override public void onEventDeleted(DeletedEvent deleteEvent) { // Update the application UI here if needed. } });
Modifier and Type | Field and Description |
---|---|
static <any> |
CREATOR |
Modifier | Constructor and Description |
---|---|
protected |
NexmoConversation(Parcel in) |
Modifier and Type | Method and Description |
---|---|
void |
addDTMFEventListener(NexmoDTMFEventListener listener)
Subscribe for DTMF events for this conversation
|
void |
addMemberEventListener(NexmoMemberEventListener listener)
Listen for incoming Member related events.
|
void |
addMessageEventListener(NexmoMessageEventListener listener)
Listen for incoming messages from this conversation.
|
void |
addNexmoConversationListener(NexmoConversationListener listener)
subscribe to NexmoConversationListener alerts
|
void |
addTypingEventListener(NexmoTypingEventListener listener)
Listen for incoming Typing related events.
|
int |
describeContents() |
boolean |
equals(java.lang.Object o) |
java.util.List<NexmoMember> |
getAllMembers()
Get all members that are JOINED/INVITED/LEFT in this conversation, synchronously.
|
java.lang.String |
getConversationId()
Get the id of this conversation, synchronously.
|
java.lang.String |
getCreationDate()
Get the creation date of this conversation, synchronously.
|
java.lang.String |
getDisplayName()
Get the display name of this conversation, synchronously.
|
void |
getEvents(com.nexmo.client.request_listener.NexmoRequestListener<java.util.Collection<NexmoEvent>> listener)
Retrieve the entire event history of this NexmoConversation.
|
java.lang.String |
getLastEventId()
Get the Id of the last NexmoEvent in this conversation, synchronously.
|
NexmoMember |
getMember(java.lang.String memberId) |
NexmoMember |
getMyMember()
Get the member of the current user in this conversation, synchronously.
|
java.lang.String |
getName()
Get the name of this conversation, synchronously.
|
NexmoUser |
getUser() |
int |
hashCode() |
void |
join(com.nexmo.client.request_listener.NexmoRequestListener<NexmoMember> listener)
Join the current logged in
NexmoUser to this conversation. |
void |
join(java.lang.String username,
com.nexmo.client.request_listener.NexmoRequestListener<java.lang.String> listener)
Join a
NexmoUser to this conversation. |
void |
kick(NexmoMember member,
com.nexmo.client.request_listener.NexmoRequestListener listener)
Remove a
NexmoUser from this conversation. |
void |
removeDTMFEventListener(NexmoDTMFEventListener listener)
Unsubscribe from DTMF events
|
void |
removeMemberEventListener(NexmoMemberEventListener listener)
Unsubscribe from incoming Member related events.
|
void |
removeMessageEventListener(NexmoMessageEventListener listener)
Unsubscribe from incoming Message related events.
|
void |
removeNexmoConversationListener(NexmoConversationListener listener)
Unsubscribe from incoming Message related events.
|
void |
removeTypingEventListener(NexmoTypingEventListener listener)
Unsubscribe from incoming Typing related events.
|
void |
sendAttachment(java.io.File attachment,
com.nexmo.client.request_listener.NexmoRequestListener listener)
Send/Upload an attachment to a conversation.
|
void |
sendText(java.lang.String text,
com.nexmo.client.request_listener.NexmoRequestListener listener)
Send a Text event to a conversation.
|
void |
startTyping()
Send a typing indicator ON event to the conversation.
|
void |
stopTyping()
Send a typing indicator OFF event to the conversation.
|
java.lang.String |
toString() |
void |
writeToParcel(Parcel dest,
int flags) |
public void getEvents(com.nexmo.client.request_listener.NexmoRequestListener<java.util.Collection<NexmoEvent>> listener)
listener
- The request completion listener.public void sendText(java.lang.String text, com.nexmo.client.request_listener.NexmoRequestListener listener)
text
- The text payload.listener
- The request completion listener.public void sendAttachment(java.io.File attachment, com.nexmo.client.request_listener.NexmoRequestListener listener)
Once the image is uploaded, you will be able to access all 3 representations:
NexmoAttachmentEvent.getOriginal()
NexmoAttachmentEvent.getMedium()
NexmoAttachmentEvent.getThumbnail()
TODO implement cancellable upload CSA-814
attachment
- The attachment file.listener
- The request completion listener.public void join(com.nexmo.client.request_listener.NexmoRequestListener<NexmoMember> listener)
NexmoUser
to this conversation.
Note: any NexmoUser
that joins a NexmoConversation
becomes a NexmoMember
.
listener
- The request completion listener.public void join(java.lang.String username, com.nexmo.client.request_listener.NexmoRequestListener<java.lang.String> listener)
NexmoUser
to this conversation.
Note: any NexmoUser
that joins a NexmoConversation
becomes a NexmoMember
.
username
- The username of the user that will join this NexmoConversation.listener
- The request completion listener.public void kick(NexmoMember member, com.nexmo.client.request_listener.NexmoRequestListener listener)
NexmoUser
from this conversation.member
- The member to be removed.listener
- The request completion listener.public void startTyping()
public void stopTyping()
public NexmoUser getUser()
public NexmoMember getMember(java.lang.String memberId)
public void addNexmoConversationListener(NexmoConversationListener listener)
listener
- NexmoConversationListener.public void removeNexmoConversationListener(NexmoConversationListener listener)
listener
- NexmoConversationListener.public void addMessageEventListener(NexmoMessageEventListener listener)
Event types:
listener
- Event listener.public void removeMessageEventListener(NexmoMessageEventListener listener)
listener
- Event listener.public void addDTMFEventListener(NexmoDTMFEventListener listener)
listener
- public void removeDTMFEventListener(NexmoDTMFEventListener listener)
listener
- public void addMemberEventListener(NexmoMemberEventListener listener)
listener
- Event listener.public void removeMemberEventListener(NexmoMemberEventListener listener)
listener
- Event listener.public void addTypingEventListener(NexmoTypingEventListener listener)
listener
- Event listener.public void removeTypingEventListener(NexmoTypingEventListener listener)
listener
- Event listener.public java.lang.String getConversationId()
public java.lang.String getName()
public java.lang.String getDisplayName()
public java.lang.String getCreationDate()
public java.lang.String getLastEventId()
public NexmoMember getMyMember()
public final java.util.List<NexmoMember> getAllMembers()
public int describeContents()
public void writeToParcel(Parcel dest, int flags)
public java.lang.String toString()
toString
in class java.lang.Object
public boolean equals(java.lang.Object o)
equals
in class java.lang.Object
public int hashCode()
hashCode
in class java.lang.Object