hyphenate_SDK3.0  3.5.6
hyphenatejavaIMSDK
Classes | Public Member Functions | Static Public Member Functions | Static Public Attributes | List of all members
com.hyphenate.chat.EMMessage Class Reference
Inheritance diagram for com.hyphenate.chat.EMMessage:
Inheritance graph
[legend]
Collaboration diagram for com.hyphenate.chat.EMMessage:
Collaboration graph
[legend]

Classes

enum  ChatType
 
enum  Direct
 
class  EMCallbackHolder
 
enum  Status
 
enum  Type
 

Public Member Functions

Status status ()
 
 EMMessage (EMAMessage message)
 
void setStatus (Status status)
 
Type getType ()
 
EMMessageBody getBody ()
 
long getMsgTime ()
 
void setMsgTime (long msgTime)
 
long localTime ()
 
void setLocalTime (long serverTime)
 
void addBody (EMMessageBody body)
 
String getFrom ()
 
void setFrom (String from)
 
void setTo (String to)
 
String getTo ()
 
String getMsgId ()
 
void setMsgId (String msgId)
 
synchronized void setMessageStatusCallback (EMCallBack callback)
 
String toString ()
 
void setAttribute (String attribute, boolean value)
 
void setAttribute (String attribute, int value)
 
void setAttribute (String attribute, long value)
 
void setAttribute (String attribute, JSONObject value)
 
void setAttribute (String attribute, JSONArray value)
 
void setAttribute (String attribute, String value)
 
boolean getBooleanAttribute (String attribute) throws HyphenateException
 
boolean getBooleanAttribute (String attribute, boolean defaultValue)
 
int getIntAttribute (String attribute, int defaultValue)
 
long getLongAttribute (String attribute, long defaultValue)
 
int getIntAttribute (String attribute) throws HyphenateException
 
long getLongAttribute (String attribute) throws HyphenateException
 
String getStringAttribute (String attribute) throws HyphenateException
 
String getStringAttribute (String attribute, String defaultValue)
 
JSONObject getJSONObjectAttribute (String attribute) throws HyphenateException
 
JSONArray getJSONArrayAttribute (String attribute) throws HyphenateException
 
ChatType getChatType ()
 
void setChatType (ChatType chatType)
 
int describeContents ()
 
void writeToParcel (Parcel out, int flags)
 
Object clone () throws CloneNotSupportedException
 
boolean isAcked ()
 
void setAcked (boolean isAcked)
 
boolean isDelivered ()
 
void setDelivered (boolean isDelivered)
 
boolean isUnread ()
 
void setUnread (boolean unread)
 
boolean isListened ()
 
void setListened (boolean isListened)
 
String getUserName ()
 
void setDeliverAcked (boolean isDeliverAcked)
 
int progress ()
 
void setProgress (int progress)
 
Direct direct ()
 
void setDirection (Direct dir)
 
String conversationId ()
 
Map< String, Object > ext ()
 
- Public Member Functions inherited from com.hyphenate.chat.EMBase< EMAMessage >
boolean equals (Object o)
 
int hashCode ()
 

Static Public Member Functions

static EMMessage createSendMessage (Type type)
 
static EMMessage createReceiveMessage (Type type)
 
static EMMessage createTxtSendMessage (String content, String username)
 
static EMMessage createVoiceSendMessage (String filePath, int timeLength, String username)
 
static EMMessage createImageSendMessage (String filePath, boolean sendOriginalImage, String username)
 
static EMMessage createVideoSendMessage (String videofilePath, String imageThumbPath, int timeLength, String username)
 
static EMMessage createLocationSendMessage (double latitude, double longitude, String locationAddress, String username)
 
static EMMessage createFileSendMessage (String filePath, String username)
 

Static Public Attributes

static final Parcelable.Creator< EMMessageCREATOR
 

Additional Inherited Members

- Protected Attributes inherited from com.hyphenate.chat.EMBase< EMAMessage >
emaObject
 

Detailed Description

represent a sent/recv message

construct a new send text message

     EMMessage msg = EMMessage.createSendMessage(EMMessage.Type.TXT);
     msg.setTo("user1");
     TextMessageBody body = new TextMessageBody("hello from hyphenate sdk");
     msg.addBody(body);
 

construct a new recv text message

      EMMessage msg = EMMessage.createSendMessage(EMMessage.Type.IMAGE);
      msg.setTo("user1");
      ImageMessageBody body = new ImageMessageBody(imageFileUrl);
      msg.addBody(body);
 

Member Function Documentation

void com.hyphenate.chat.EMMessage.addBody ( EMMessageBody  body)

add a message body,only support add one now

Parameters
bodythe message body
static EMMessage com.hyphenate.chat.EMMessage.createFileSendMessage ( String  filePath,
String  username 
)
static

create a normal file send message

Parameters
filePaththe path of the file
usernamethe recipient id
Returns
static EMMessage com.hyphenate.chat.EMMessage.createImageSendMessage ( String  filePath,
boolean  sendOriginalImage,
String  username 
)
static

create a image send message

Parameters
filePaththe path of the image
sendOriginalImagewhether to send the original(if image greater than 100k sdk will be compressed)
usernamethe recipient id
Returns
static EMMessage com.hyphenate.chat.EMMessage.createLocationSendMessage ( double  latitude,
double  longitude,
String  locationAddress,
String  username 
)
static

create a location send message

Parameters
latitudethe latitude
longitudethe longitude
locationAddresslocation details
usernamethe recipient id
Returns
static EMMessage com.hyphenate.chat.EMMessage.createReceiveMessage ( Type  type)
static

create a new recv message

Parameters
typemessage type
Returns
the message object
static EMMessage com.hyphenate.chat.EMMessage.createSendMessage ( Type  type)
static

create a new send message

Parameters
typethe message type
Returns
the message object
static EMMessage com.hyphenate.chat.EMMessage.createTxtSendMessage ( String  content,
String  username 
)
static
Parameters
contenttext content
usernamethe recipient(user or group) id
Returns
static EMMessage com.hyphenate.chat.EMMessage.createVideoSendMessage ( String  videofilePath,
String  imageThumbPath,
int  timeLength,
String  username 
)
static

create a video send message

Parameters
videofilePaththe path of the video file
imageThumbPaththe path of the thumbnail
timeLengththe length of the video time, unit s
usernamethe recipient id
Returns
static EMMessage com.hyphenate.chat.EMMessage.createVoiceSendMessage ( String  filePath,
int  timeLength,
String  username 
)
static

create a voice send message

Parameters
filePaththe path of the voice file
timeLengththe time length of the voice(unit s)
usernamethe recipient id
Returns
Direct com.hyphenate.chat.EMMessage.direct ( )

the message direction

Map<String, Object> com.hyphenate.chat.EMMessage.ext ( )

get message extension, return type is Map&#60;String, Object&#62;

Returns
return message extension, return type is Map&#60;String, Object&#62; Object can be Boolean, Integer, Long, Float, Double, String If the input is JsonObject or JsonArray, which use setAttribute(String attribute, JSONObject json) to passed in, the Map.Entry.value type is String.
EMMessageBody com.hyphenate.chat.EMMessage.getBody ( )

get message body

Returns
boolean com.hyphenate.chat.EMMessage.getBooleanAttribute ( String  attribute) throws HyphenateException

get a boolean type extra attribute

Parameters
attributethe attribute name return
Exceptions
HyphenateException
boolean com.hyphenate.chat.EMMessage.getBooleanAttribute ( String  attribute,
boolean  defaultValue 
)

get a boolean type extra attribute

Parameters
attributethe attribute name
defaultValuethe default value you want
Returns
ChatType com.hyphenate.chat.EMMessage.getChatType ( )

get chat type

Returns
ChatType
String com.hyphenate.chat.EMMessage.getFrom ( )

get the sender id

Returns
user id
int com.hyphenate.chat.EMMessage.getIntAttribute ( String  attribute,
int  defaultValue 
)

get a int type extra attribute

Parameters
attributethe attribute name
defaultValuethe default value you want
Returns
int com.hyphenate.chat.EMMessage.getIntAttribute ( String  attribute) throws HyphenateException

get a int type extra attribute

Parameters
attributethe attribute name
Returns
the value
Exceptions
HyphenateException
JSONArray com.hyphenate.chat.EMMessage.getJSONArrayAttribute ( String  attribute) throws HyphenateException

get a jsonarray type attribute

Parameters
attribute
Returns
the value
Exceptions
HyphenateException
JSONObject com.hyphenate.chat.EMMessage.getJSONObjectAttribute ( String  attribute) throws HyphenateException

get a jsonobject type attribute

Parameters
attribute
Returns
the value
Exceptions
HyphenateException
long com.hyphenate.chat.EMMessage.getLongAttribute ( String  attribute,
long  defaultValue 
)

get a long type extra attribute

Parameters
attributethe attribute name
defaultValuethe default value you want
Returns
long com.hyphenate.chat.EMMessage.getLongAttribute ( String  attribute) throws HyphenateException

get long type extra attribute

Parameters
attributethe attribute name
Returns
the value
Exceptions
HyphenateException
String com.hyphenate.chat.EMMessage.getMsgId ( )

get message id

Returns
id
long com.hyphenate.chat.EMMessage.getMsgTime ( )

get message time stamp(server time)

Returns
String com.hyphenate.chat.EMMessage.getStringAttribute ( String  attribute) throws HyphenateException

get a string type extra attribute

Parameters
attributethe attribute name
Returns
the value
Exceptions
HyphenateException
String com.hyphenate.chat.EMMessage.getStringAttribute ( String  attribute,
String  defaultValue 
)

get a string type extra attribute

Parameters
attributethe attribute name
defaultValuethe default value you want
Returns
String com.hyphenate.chat.EMMessage.getTo ( )

get receiver name

Returns
Type com.hyphenate.chat.EMMessage.getType ( )

获取消息类型

Returns

get message chat type

Returns
String com.hyphenate.chat.EMMessage.getUserName ( )

get the peer's id

boolean com.hyphenate.chat.EMMessage.isAcked ( )

Read Ack

boolean com.hyphenate.chat.EMMessage.isDelivered ( )

Delivery Ack, check if the peer has received the message

boolean com.hyphenate.chat.EMMessage.isListened ( )

get whether the message is listen

boolean com.hyphenate.chat.EMMessage.isUnread ( )

unread flag

long com.hyphenate.chat.EMMessage.localTime ( )

get local receive time

Returns
int com.hyphenate.chat.EMMessage.progress ( )

indicate message attachment upload or download progress, value ranges between 0-100. for message attachment's thumbnail, it doesn't has progress information

Returns
void com.hyphenate.chat.EMMessage.setAcked ( boolean  isAcked)

Sets whether the other has been read, not suppposed to be called by app

void com.hyphenate.chat.EMMessage.setAttribute ( String  attribute,
boolean  value 
)

set a boolean type extra attributes of the message

Parameters
attributeattribute key
valueattribute value
void com.hyphenate.chat.EMMessage.setAttribute ( String  attribute,
int  value 
)

set a int type extra attributes of the message

Parameters
attributeattribute key
valueattribute value
void com.hyphenate.chat.EMMessage.setAttribute ( String  attribute,
long  value 
)

set a long type extra attributes of the message

Parameters
attributeattribute key
valueattribute value
void com.hyphenate.chat.EMMessage.setAttribute ( String  attribute,
JSONObject  value 
)

set a jsonobject type extra attributes of the message

Parameters
attributeattribute key
valueattribute value
void com.hyphenate.chat.EMMessage.setAttribute ( String  attribute,
JSONArray  value 
)

set a jsonarray type extra attributes of the message

Parameters
attributeattribute key
valueattribute value
void com.hyphenate.chat.EMMessage.setAttribute ( String  attribute,
String  value 
)

set a string type extra attributes of the message

Parameters
attributeattribute key
valueattribute value
void com.hyphenate.chat.EMMessage.setChatType ( ChatType  chatType)

set chat type, the default is single chat ChatType.Chat

Parameters
chatType
See also
ChatType
void com.hyphenate.chat.EMMessage.setDirection ( Direct  dir)

set message direction

Parameters
dir
void com.hyphenate.chat.EMMessage.setFrom ( String  from)

set sender id

Parameters
from
void com.hyphenate.chat.EMMessage.setListened ( boolean  isListened)

Sets whether the other has been listen

Parameters
isListened
void com.hyphenate.chat.EMMessage.setLocalTime ( long  serverTime)

set message local receive time

Parameters
serverTime
synchronized void com.hyphenate.chat.EMMessage.setMessageStatusCallback ( EMCallBack  callback)

set message status callback, your app should set emaObject callback to get message status and then refresh the ui accordingly

Parameters
callback
void com.hyphenate.chat.EMMessage.setMsgId ( String  msgId)

set local message id

Parameters
msgId
void com.hyphenate.chat.EMMessage.setMsgTime ( long  msgTime)

set message time stamp(server time)

Parameters
msgTime
void com.hyphenate.chat.EMMessage.setProgress ( int  progress)

for app developing, it doesn't need set progress.

Parameters
progress
void com.hyphenate.chat.EMMessage.setStatus ( Status  status)

set the status of the message

void com.hyphenate.chat.EMMessage.setTo ( String  to)

set receiver name

Parameters
to
Status com.hyphenate.chat.EMMessage.status ( )

message status

Member Data Documentation

final Parcelable.Creator<EMMessage> com.hyphenate.chat.EMMessage.CREATOR
static
Initial value:
= new Parcelable.Creator<EMMessage>() {
public EMMessage createFromParcel(Parcel in) {
EMMessage msg = null;
try {
msg = new EMMessage(in);
} catch (HyphenateException e) {
e.printStackTrace();
}
return msg;
}
public EMMessage[] newArray(int size) {
return new EMMessage[size];
}
}

The documentation for this class was generated from the following file: