public class MessageBuilder
extends java.lang.Object
Constructor and Description |
---|
MessageBuilder() |
Modifier and Type | Method and Description |
---|---|
static java.lang.String |
convertMessageToJson(IMMessage msg)
Convert IMMessages into JSON file
|
static IMMessage |
createAudioMessage(java.lang.String sessionId,
SessionTypeEnum sessionType,
java.io.File file,
long duration)
Create an audio message
|
static IMMessage |
createAudioMessage(java.lang.String sessionId,
SessionTypeEnum sessionType,
java.io.File file,
long duration,
java.lang.String nosTokenSceneKey)
Create an audio message and specify the NOS scene key for upload.
|
static IMMessage |
createCustomMessage(java.lang.String sessionId,
SessionTypeEnum sessionType,
MsgAttachment attachment)
Create a custom message
|
static IMMessage |
createCustomMessage(java.lang.String sessionId,
SessionTypeEnum sessionType,
java.lang.String content,
MsgAttachment attachment)
Create a custom message with a description field used for push or alert on the status bar.
|
static IMMessage |
createCustomMessage(java.lang.String sessionId,
SessionTypeEnum sessionType,
java.lang.String content,
MsgAttachment attachment,
CustomMessageConfig config)
Create a custom message with a description field used for push or alert on the status bar.
|
static IMMessage |
createCustomMessage(java.lang.String sessionId,
SessionTypeEnum sessionType,
java.lang.String content,
MsgAttachment attachment,
CustomMessageConfig config,
java.lang.String nosTokenSceneKey)
Create a custom message with a description field used for push or alert on the status bar.
|
static IMMessage |
createEmptyMessage(java.lang.String sessionId,
SessionTypeEnum sessionType,
long time)
Create an empty message with only the session and the time for query
|
static IMMessage |
createFileMessage(java.lang.String sessionId,
SessionTypeEnum sessionType,
java.io.File file,
java.lang.String displayName)
Create a file message
|
static IMMessage |
createFileMessage(java.lang.String sessionId,
SessionTypeEnum sessionType,
java.io.File file,
java.lang.String displayName,
java.lang.String nosTokenSceneKey)
Create a file message and specify the NOS scene key for upload
|
static IMMessage |
createForwardMessage(IMMessage message,
java.lang.String sessionId,
SessionTypeEnum sessionType)
Create a message to be forwarded
|
static java.lang.String |
createForwardMessageListFileDetail(java.util.List<? extends IMMessage> messages)
Create messages to be forwarded
|
static IMMessage |
createFromJson(java.lang.String json)
Create IMMessages from JSON strings
|
static IMMessage |
createImageMessage(java.lang.String sessionId,
SessionTypeEnum sessionType,
java.io.File file)
Create an image message.
|
static IMMessage |
createImageMessage(java.lang.String sessionId,
SessionTypeEnum sessionType,
java.io.File file,
java.lang.String displayName)
Create an image message
|
static IMMessage |
createImageMessage(java.lang.String sessionId,
SessionTypeEnum sessionType,
java.io.File file,
java.lang.String displayName,
java.lang.String nosTokenSceneKey)
Create an image message and specify the NOS scene key for upload.
|
static IMMessage |
createLocationMessage(java.lang.String sessionId,
SessionTypeEnum sessionType,
double lat,
double lng,
java.lang.String addr)
Create a location message
|
static IMMessage |
createNrtcNetcallMessage(java.lang.String sessionId,
SessionTypeEnum sessionType,
MsgAttachment netCallAttachment)
Create a call message
|
static IMMessage |
createRobotMessage(java.lang.String sessionId,
SessionTypeEnum sessionType,
java.lang.String robotAccount,
java.lang.String text,
java.lang.String type,
java.lang.String content,
java.lang.String target,
java.lang.String params) |
static IMMessage |
createTextMessage(java.lang.String sessionId,
SessionTypeEnum sessionType,
java.lang.String text)
Create a text message
|
static IMMessage |
createTipMessage(java.lang.String sessionId,
SessionTypeEnum sessionType)
Create a tip message
|
static IMMessage |
createVideoMessage(java.lang.String sessionId,
SessionTypeEnum sessionType,
java.io.File file,
long duration,
int width,
int height,
java.lang.String displayName)
Create a video message
|
static IMMessage |
createVideoMessage(java.lang.String sessionId,
SessionTypeEnum sessionType,
java.io.File file,
long duration,
int width,
int height,
java.lang.String displayName,
java.lang.String nosTokenSceneKey)
Create a video message and specify the NOS scene key for upload
|
public static IMMessage createTextMessage(java.lang.String sessionId, SessionTypeEnum sessionType, java.lang.String text)
sessionId
- Session IDsessionType
- Session typetext
- message contentpublic static IMMessage createImageMessage(java.lang.String sessionId, SessionTypeEnum sessionType, java.io.File file)
sessionId
- Session IDsessionType
- Session typefile
- Image filepublic static IMMessage createImageMessage(java.lang.String sessionId, SessionTypeEnum sessionType, java.io.File file, java.lang.String displayName)
sessionId
- Session IDsessionType
- Session typefile
- Image filedisplayName
- The display name of an image file that can be different from the file name.public static IMMessage createImageMessage(java.lang.String sessionId, SessionTypeEnum sessionType, java.io.File file, java.lang.String displayName, java.lang.String nosTokenSceneKey)
sessionId
- Session IDsessionType
- Session typefile
- Image filedisplayName
- The display name of an image file that can be different from the file name.nosTokenSceneKey
- The NOS scene key of an image used for upload. The default value is NimNosSceneKeyConstant#NIM_DEFAULT_IM
.public static IMMessage createAudioMessage(java.lang.String sessionId, SessionTypeEnum sessionType, java.io.File file, long duration)
sessionId
- Session IDsessionType
- Session typefile
- audio fileduration
- The duration of an audio file. Unit: millisecondspublic static IMMessage createAudioMessage(java.lang.String sessionId, SessionTypeEnum sessionType, java.io.File file, long duration, java.lang.String nosTokenSceneKey)
sessionId
- Session IDsessionType
- Session typefile
- audio fileduration
- The duration of an audio file. Unit: millisecondsnosTokenSceneKey
- The NOS scene key of an audio file used for upload. The default value is NimNosSceneKeyConstant#NIM_DEFAULT_IM
.public static IMMessage createLocationMessage(java.lang.String sessionId, SessionTypeEnum sessionType, double lat, double lng, java.lang.String addr)
sessionId
- Session IDsessionType
- Session typelat
- Latitudelng
- Longitudeaddr
- The location descriptionpublic static IMMessage createVideoMessage(java.lang.String sessionId, SessionTypeEnum sessionType, java.io.File file, long duration, int width, int height, java.lang.String displayName)
sessionId
- Session IDsessionType
- Session typefile
- Video fileduration
- Duration of a video filewidth
- Video widthheight
- Video heightdisplayName
- The display name of the video file. The parameter can be empty.public static IMMessage createVideoMessage(java.lang.String sessionId, SessionTypeEnum sessionType, java.io.File file, long duration, int width, int height, java.lang.String displayName, java.lang.String nosTokenSceneKey)
sessionId
- Session IDsessionType
- Session typefile
- Video fileduration
- Duration of a video filewidth
- Video widthheight
- Video heightdisplayName
- The display name of the video file. The parameter can be empty.nosTokenSceneKey
- The NOS scene key of a video file used for upload. The default value is NimNosSceneKeyConstant#NIM_DEFAULT_IM
.public static IMMessage createFileMessage(java.lang.String sessionId, SessionTypeEnum sessionType, java.io.File file, java.lang.String displayName)
sessionId
- Session IDsessionType
- Session typefile
- FiledisplayName
- The display name of the file that can be different from the file name.public static IMMessage createFileMessage(java.lang.String sessionId, SessionTypeEnum sessionType, java.io.File file, java.lang.String displayName, java.lang.String nosTokenSceneKey)
sessionId
- Session IDsessionType
- Session typefile
- FiledisplayName
- The display name of the file that can be different from the file name.nosTokenSceneKey
- The NOS scene key used for upload. The default value is NimNosSceneKeyConstant#NIM_DEFAULT_IM
.public static IMMessage createTipMessage(java.lang.String sessionId, SessionTypeEnum sessionType)
sessionId
- Session IDsessionType
- Session typepublic static IMMessage createCustomMessage(java.lang.String sessionId, SessionTypeEnum sessionType, MsgAttachment attachment)
sessionId
- Session IDsessionType
- Session typeattachment
- Attachment of a messagepublic static IMMessage createCustomMessage(java.lang.String sessionId, SessionTypeEnum sessionType, java.lang.String content, MsgAttachment attachment)
sessionId
- Session IDsessionType
- Session typecontent
- Message description that can be obtained by calling IMMessage#getContent(). The description of the message will be displayed for push services.attachment
- Attachment of a messagepublic static IMMessage createCustomMessage(java.lang.String sessionId, SessionTypeEnum sessionType, java.lang.String content, MsgAttachment attachment, CustomMessageConfig config)
sessionId
- Session IDsessionType
- Session typecontent
- Message description that can be obtained by calling IMMessage#getContent(). The description of the message will be displayed for push services.attachment
- Attachment of a messageconfig
- The configuration of a custom messagepublic static IMMessage createCustomMessage(java.lang.String sessionId, SessionTypeEnum sessionType, java.lang.String content, MsgAttachment attachment, CustomMessageConfig config, java.lang.String nosTokenSceneKey)
sessionId
- Session IDsessionType
- Session typecontent
- Message description that can be obtained by calling IMMessage#getContent(). The description of the message will be displayed for push services.attachment
- Attachment of a messageconfig
- The configuration of a custom messagenosTokenSceneKey
- The NOS scene key for upload if anypublic static IMMessage createRobotMessage(java.lang.String sessionId, SessionTypeEnum sessionType, java.lang.String robotAccount, java.lang.String text, java.lang.String type, java.lang.String content, java.lang.String target, java.lang.String params)
sessionId
- Session IDsessionType
- Session typerobotAccount
- Bot accounttext
- The message text. In most cases, the display message contains the content plus @bot tag.type
- Bot message type. For more information, see RobotMsgType
content
- The message content. If the message type is RobotMsgType.TEXT
, the content must be specified.target
- If the message type is RobotMsgType.LINK
, the target link that is redirected to must be specified.params
- If the message type is RobotMsgType.LINK
, parameters must be specified.public static IMMessage createNrtcNetcallMessage(java.lang.String sessionId, SessionTypeEnum sessionType, MsgAttachment netCallAttachment)
sessionId
- The session IDsessionType
- The session typenetCallAttachment
- The call attachment objectpublic static IMMessage createEmptyMessage(java.lang.String sessionId, SessionTypeEnum sessionType, long time)
sessionId
- Session IDsessionType
- Session typetime
- The start time of querypublic static IMMessage createForwardMessage(IMMessage message, java.lang.String sessionId, SessionTypeEnum sessionType)
message
- The messagesessionId
- Session IDsessionType
- Session typepublic static java.lang.String createForwardMessageListFileDetail(java.util.List<? extends IMMessage> messages)
messages
- The messages to be forwardedpublic static IMMessage createFromJson(java.lang.String json)
json
- Data sourcepublic static java.lang.String convertMessageToJson(IMMessage msg)
msg
- Message body