NIMSDK-AOS  10.9.70
ChatRoomMessageBuilder.java
浏览该文件的文档.
1 package com.netease.nimlib.sdk.chatroom;
2 
3 import android.content.Context;
4 import android.net.Uri;
5 import android.text.TextUtils;
6 
7 import com.netease.nimlib.NimNosSceneKeyConstant;
8 import com.netease.nimlib.SDKCacheUI;
9 import com.netease.nimlib.chatroom.model.ChatRoomMessageImpl;
10 import com.netease.nimlib.report.utils.NtpTimeUtil;
26 import com.netease.nimlib.util.BitmapDecoder;
27 import com.netease.nimlib.util.StringUtil;
28 import com.netease.nimlib.util.TimeUtil;
29 
30 import java.io.File;
31 
32 /**
33  * 聊天室消息构造器
34  */
35 public class ChatRoomMessageBuilder {
36 
37  /**
38  * 创建普通文本消息
39  *
40  * @param roomId 聊天室ID
41  * @param text 文本消息内容
42  * @return ChatRoomMessage 生成的聊天室消息对象
43  */
44  public static ChatRoomMessage createChatRoomTextMessage(String roomId, String text) {
45  ChatRoomMessageImpl msg = initSendMessage(roomId);
46  msg.setMsgType(MsgTypeEnum.text.getValue());
47  msg.setContent(text);
48 
49  return msg;
50  }
51 
52  /**
53  * 创建自定义消息
54  *
55  * @param roomId 聊天室ID
56  * @param attachment 消息附件对象
57  * @return ChatRoomMessage 生成的自定义消息对象
58  */
59  public static ChatRoomMessage createChatRoomCustomMessage(String roomId, MsgAttachment attachment) {
60  return createChatRoomCustomMessage(roomId, attachment, NimNosSceneKeyConstant.NIM_DEFAULT_IM);
61  }
62 
63  /**
64  * 创建自定义消息 另外指定指定文件上传(如果有)时使用的 nos scene
65  *
66  * @param roomId 聊天室ID
67  * @param attachment 消息附件对象
68  * @param nosTokenScene 文件上传(如果有)时使用的 nos scene
69  * @return ChatRoomMessage 生成的自定义消息对象
70  */
71  public static ChatRoomMessage createChatRoomCustomMessage(String roomId, MsgAttachment attachment, String nosTokenScene) {
72  ChatRoomMessageImpl msg = initSendMessage(roomId);
73  msg.setMsgType(MsgTypeEnum.custom.getValue());
74  if (attachment != null && attachment instanceof FileAttachment) {
75  ((FileAttachment) attachment).setNosTokenSceneKey(nosTokenScene);
76  }
77  msg.setAttachment(attachment);
78 
79  return msg;
80  }
81 
82  /**
83  * 创建一条图片消息
84  *
85  * @param roomId 聊天室ID
86  * @param file 图片文件
87  * @param displayName 图片文件的显示名,可不同于文件名
88  * @return ChatRoomMessage 生成的聊天室消息对象
89  */
90  public static ChatRoomMessage createChatRoomImageMessage(String roomId, File file, String displayName) {
91  return createChatRoomImageMessage(roomId, file, displayName, NimNosSceneKeyConstant.NIM_DEFAULT_IM);
92  }
93 
94  /**
95  * 创建一条图片消息
96  *
97  * @param context Context
98  * @param roomId 聊天室ID
99  * @param uri 图片uri
100  * @param displayName 图片文件的显示名,可不同于文件名
101  * @return ChatRoomMessage 生成的聊天室消息对象
102  */
103  public static ChatRoomMessage createChatRoomImageMessage(Context context,String roomId, Uri uri, String displayName) {
104  return createChatRoomImageMessage(context,roomId, uri, displayName, NimNosSceneKeyConstant.NIM_DEFAULT_IM);
105  }
106 
107 
108 
109  /**
110  * 创建一条图片消息 并指定图片上传时使用的 nos scene
111  *
112  * @param roomId 聊天室ID
113  * @param file 图片文件
114  * @param displayName 图片文件的显示名,可不同于文件名
115  * @param nosTokenSceneKey 图片上传时使用的 nos scene ,默认为 {@link NimNosSceneKeyConstant#NIM_DEFAULT_IM}
116  * @return ChatRoomMessage 生成的聊天室消息对象
117  */
118  public static ChatRoomMessage createChatRoomImageMessage(String roomId, File file, String displayName, String nosTokenSceneKey) {
119  ChatRoomMessageImpl msg = initSendMessage(roomId);
120  msg.setMsgType(MsgTypeEnum.image.getValue());
121 
122  final ImageAttachment attachment = MessageBuilder.createImageAttachment(file, displayName,nosTokenSceneKey);
123  msg.setAttachment(attachment);
124 
125  return msg;
126  }
127 
128  /**
129  * 创建一条图片消息 并指定图片上传时使用的 nos scene
130  *
131  * @param roomId 聊天室ID
132  * @param uri 图片文件uri
133  * @param displayName 图片文件的显示名,可不同于文件名
134  * @param nosTokenSceneKey 图片上传时使用的 nos scene ,默认为 {@link NimNosSceneKeyConstant#NIM_DEFAULT_IM}
135  * @return ChatRoomMessage 生成的聊天室消息对象
136  */
137  public static ChatRoomMessage createChatRoomImageMessage(Context context,String roomId, Uri uri, String displayName, String nosTokenSceneKey) {
138  ChatRoomMessageImpl msg = initSendMessage(roomId);
139  msg.setMsgType(MsgTypeEnum.image.getValue());
140  final ImageAttachment attachment = MessageBuilder.createImageAttachment(context,uri,displayName,nosTokenSceneKey);
141  msg.setAttachment(attachment);
142 
143  return msg;
144  }
145 
146 
147  /**
148  * 创建一条音频消息
149  *
150  * @param roomId 聊天室ID
151  * @param file 音频文件对象
152  * @param duration 音频文件持续时间,单位是ms
153  * @return ChatRoomMessage 生成的聊天室消息对象
154  */
155  public static ChatRoomMessage createChatRoomAudioMessage(String roomId, File file, long duration) {
156  return createChatRoomAudioMessage(roomId, file, duration, NimNosSceneKeyConstant.NIM_DEFAULT_IM);
157  }
158 
159  /**
160  * 创建一条音频消息
161  *
162  * @param context Context
163  * @param roomId 聊天室ID
164  * @param uri 音频文件uri
165  * @param duration 音频文件持续时间,单位是ms
166  * @return ChatRoomMessage 生成的聊天室消息对象
167  */
168  public static ChatRoomMessage createChatRoomAudioMessage(Context context,String roomId, Uri uri, long duration) {
169  return createChatRoomAudioMessage(context,roomId, uri, duration, NimNosSceneKeyConstant.NIM_DEFAULT_IM);
170  }
171 
172  /**
173  * 创建一条音频消息 并指定音频文件上传时使用的 nos scene
174  *
175  * @param roomId 聊天室ID
176  * @param file 音频文件对象
177  * @param duration 音频文件持续时间,单位是ms
178  * @param nosTokenSceneKey 音频文件上传时使用的 nos scene ,默认为 {@link NimNosSceneKeyConstant#NIM_DEFAULT_IM}
179  * @return ChatRoomMessage 生成的聊天室消息对象
180  */
181  public static ChatRoomMessage createChatRoomAudioMessage(String roomId, File file, long duration, String nosTokenSceneKey) {
182  ChatRoomMessageImpl msg = initSendMessage(roomId);
183  msg.setMsgType(MsgTypeEnum.audio.getValue());
184  if (duration > 0 && duration < 1000) {
185  duration = 1000; // 最低显示1秒
186  }
187 
188  final AudioAttachment attachment = MessageBuilder.createAudioAttachment(file,duration,nosTokenSceneKey);
189  msg.setAttachment(attachment);
190 
191  return msg;
192  }
193 
194  /**
195  * 创建一条音频消息 并指定音频文件上传时使用的 nos scene
196  *
197  * @param context Context
198  * @param roomId 聊天室ID
199  * @param uri 音频文件uri
200  * @param duration 音频文件持续时间,单位是ms
201  * @param nosTokenSceneKey 音频文件上传时使用的 nos scene ,默认为 {@link NimNosSceneKeyConstant#NIM_DEFAULT_IM}
202  * @return ChatRoomMessage 生成的聊天室消息对象
203  */
204  public static ChatRoomMessage createChatRoomAudioMessage(Context context,String roomId, Uri uri, long duration, String nosTokenSceneKey) {
205  ChatRoomMessageImpl msg = initSendMessage(roomId);
206  msg.setMsgType(MsgTypeEnum.audio.getValue());
207  if (duration > 0 && duration < 1000) {
208  duration = 1000; // 最低显示1秒
209  }
210  final AudioAttachment attachment = MessageBuilder.createAudioAttachment(context,uri,duration,nosTokenSceneKey);
211  msg.setAttachment(attachment);
212 
213  return msg;
214  }
215 
216  /**
217  * 创建一条地理位置信息
218  *
219  * @param roomId 聊天室ID
220  * @param lat 维度
221  * @param lng 经度
222  * @param addr 地理位置描述信息
223  * @return ChatRoomMessage 生成的聊天室消息对象
224  */
225  public static ChatRoomMessage createChatRoomLocationMessage(String roomId, double lat, double lng, String addr) {
226  ChatRoomMessageImpl msg = initSendMessage(roomId);
227  msg.setMsgType(MsgTypeEnum.location.getValue());
228 
229  final LocationAttachment location = new LocationAttachment();
230  location.setLatitude(lat);
231  location.setLongitude(lng);
232  location.setAddress(addr);
233  msg.setAttachStatus(AttachStatusEnum.transferred);
234  msg.setAttachment(location);
235 
236  return msg;
237  }
238 
239  /**
240  * 创建一条视频消息
241  *
242  * @param roomId 聊天室ID
243  * @param file 视频文件对象
244  * @param duration 视频文件持续时间
245  * @param width 视频宽度
246  * @param height 视频高度
247  * @param displayName 视频文件显示名,可以为空
248  * @return ChatRoomMessage 生成的聊天室消息对象
249  */
250  public static ChatRoomMessage createChatRoomVideoMessage(String roomId, File file, long duration, int width, int height, String displayName) {
251  return createChatRoomVideoMessage(roomId, file, duration, width, height, displayName, NimNosSceneKeyConstant.NIM_DEFAULT_IM);
252  }
253 
254  /**
255  * 创建一条视频消息
256  *
257  * @param context Context
258  * @param roomId 聊天室ID
259  * @param uri 视频文件uri
260  * @param duration 视频文件持续时间
261  * @param width 视频宽度
262  * @param height 视频高度
263  * @param displayName 视频文件显示名,可以为空
264  * @return ChatRoomMessage 生成的聊天室消息对象
265  */
266  public static ChatRoomMessage createChatRoomVideoMessage(Context context,String roomId, Uri uri, long duration, int width, int height, String displayName) {
267  return createChatRoomVideoMessage(context,roomId, uri, duration, width, height, displayName, NimNosSceneKeyConstant.NIM_DEFAULT_IM);
268  }
269 
270  /**
271  * 创建一条视频消息 并指定视频文件上传时使用的 nos scene
272  *
273  * @param roomId 聊天室ID
274  * @param file 视频文件对象
275  * @param duration 视频文件持续时间
276  * @param width 视频宽度
277  * @param height 视频高度
278  * @param displayName 视频文件显示名,可以为空
279  * @param nosTokenSceneKey 视频文件上传时使用的 nos scene ,默认为 {@link NimNosSceneKeyConstant#NIM_DEFAULT_IM}
280  * @return ChatRoomMessage 生成的聊天室消息对象
281  */
282  public static ChatRoomMessage createChatRoomVideoMessage(String roomId, File file, long duration, int width, int height, String displayName, String nosTokenSceneKey) {
283  ChatRoomMessageImpl msg = initSendMessage(roomId);
284  msg.setMsgType(MsgTypeEnum.video.getValue());
285 
286  final VideoAttachment attachment = MessageBuilder.createVideoAttachment(file, duration, width, height, displayName,nosTokenSceneKey);
287  msg.setAttachment(attachment);
288 
289  BitmapDecoder.extractThumbnail(file.getPath(), attachment.getThumbPathForSave());
290 
291  return msg;
292  }
293 
294  /**
295  * 创建一条视频消息 并指定视频文件上传时使用的 nos scene
296  *
297  * @param context Context
298  * @param roomId 聊天室ID
299  * @param uri 视频文件uri
300  * @param duration 视频文件持续时间
301  * @param width 视频宽度
302  * @param height 视频高度
303  * @param displayName 视频文件显示名,可以为空
304  * @param nosTokenSceneKey 视频文件上传时使用的 nos scene ,默认为 {@link NimNosSceneKeyConstant#NIM_DEFAULT_IM}
305  * @return ChatRoomMessage 生成的聊天室消息对象
306  */
307  @SuppressWarnings("java:S107")
308  public static ChatRoomMessage createChatRoomVideoMessage(Context context,String roomId, Uri uri, long duration, int width, int height, String displayName, String nosTokenSceneKey) {
309  ChatRoomMessageImpl msg = initSendMessage(roomId);
310  msg.setMsgType(MsgTypeEnum.video.getValue());
311 
312  final VideoAttachment attachment = MessageBuilder.createVideoAttachment(context,uri, duration, width, height, displayName,nosTokenSceneKey);
313  msg.setAttachment(attachment);
314 
315  BitmapDecoder.extractThumbnail(uri, attachment.getThumbPathForSave());
316 
317  return msg;
318  }
319 
320  /**
321  * 创建一条文件消息
322  *
323  * @param roomId 聊天室ID
324  * @param file 文件
325  * @param displayName 文件的显示名,可不同于文件名
326  * @return ChatRoomMessage 生成的聊天室消息对象
327  */
328  public static ChatRoomMessage createChatRoomFileMessage(String roomId, File file, String displayName) {
329  return createChatRoomFileMessage(roomId, file, displayName, NimNosSceneKeyConstant.NIM_DEFAULT_IM);
330  }
331 
332  /**
333  * 创建一条文件消息 并指定文件上传时使用的 nos scene
334  *
335  * @param context Context
336  * @param roomId 聊天室ID
337  * @param uri 文件uri
338  * @param displayName 文件的显示名,可不同于文件名
339  * @return ChatRoomMessage 生成的聊天室消息对象
340  */
341  public static ChatRoomMessage createChatRoomFileMessage(Context context,String roomId, Uri uri, String displayName) {
342  ChatRoomMessageImpl msg = initSendMessage(roomId);
343  msg.setMsgType(MsgTypeEnum.file.getValue());
344 
345  final FileAttachment attachment = MessageBuilder.createFileAttachment(context, uri, displayName, NimNosSceneKeyConstant.NIM_DEFAULT_IM);
346  msg.setAttachment(attachment);
347  return msg;
348  }
349 
350  /**
351  * 创建一条文件消息 并指定文件上传时使用的 nos scene
352  *
353  * @param roomId 聊天室ID
354  * @param file 文件
355  * @param displayName 文件的显示名,可不同于文件名
356  * @param nosTokenSceneKey 文件上传时使用的 nos scene ,默认为 {@link NimNosSceneKeyConstant#NIM_DEFAULT_IM}
357  * @return ChatRoomMessage 生成的聊天室消息对象
358  */
359  public static ChatRoomMessage createChatRoomFileMessage(String roomId, File file, String displayName, String nosTokenSceneKey) {
360  ChatRoomMessageImpl msg = initSendMessage(roomId);
361  msg.setMsgType(MsgTypeEnum.file.getValue());
362 
363  final FileAttachment attachment = MessageBuilder.createFileAttachment(file, displayName, nosTokenSceneKey);
364  msg.setAttachment(attachment);
365  return msg;
366  }
367 
368  /**
369  * 创建一条文件消息 并指定文件上传时使用的 nos scene
370  *
371  * @param context Context
372  * @param roomId 聊天室ID
373  * @param uri 文件uri
374  * @param displayName 文件的显示名,可不同于文件名
375  * @param nosTokenSceneKey 文件上传时使用的 nos scene ,默认为 {@link NimNosSceneKeyConstant#NIM_DEFAULT_IM}
376  * @return ChatRoomMessage 生成的聊天室消息对象
377  */
378  public static ChatRoomMessage createChatRoomFileMessage(Context context,String roomId, Uri uri, String displayName, String nosTokenSceneKey) {
379  ChatRoomMessageImpl msg = initSendMessage(roomId);
380  msg.setMsgType(MsgTypeEnum.file.getValue());
381 
382  final FileAttachment attachment = MessageBuilder.createFileAttachment(context, uri, displayName, nosTokenSceneKey);
383  msg.setAttachment(attachment);
384  return msg;
385  }
386 
387  /**
388  * 创建普通文本消息
389  *
390  * @param roomId 聊天室ID
391  * @param text 文本消息内容
392  * @param x 坐标X
393  * @param y 坐标Y
394  * @param z 坐标Z
395  * @return ChatRoomMessage 生成的聊天室消息对象
396  */
397  public static ChatRoomMessage createChatRoomSpatialLocationTextMessage(String roomId, String text,Double x,Double y,Double z) {
398  ChatRoomMessageImpl msg = initSendMessage(roomId);
399  msg.setMsgType(MsgTypeEnum.text.getValue());
400  msg.setContent(text);
401  msg.setLocX(x);
402  msg.setLocY(y);
403  msg.setLocZ(z);
404  return msg;
405  }
406 
407  /**
408  * 创建一条提醒消息
409  *
410  * @param roomId 聊天室ID
411  * @return ChatRoomMessage 生成的聊天室消息对象
412  */
413  public static ChatRoomMessage createTipMessage(String roomId) {
414  ChatRoomMessageImpl msg = initSendMessage(roomId);
415  msg.setMsgType(MsgTypeEnum.tip.getValue());
416 
417  return msg;
418  }
419 
420  /**
421  * @param roomId 聊天室ID
422  * @param robotAccount 机器人账号
423  * @param text 消息显示的文案,一般基于content加上@机器人的标签作为消息显示的文案。
424  * @param type 机器人消息类型,参考{@link com.netease.nimlib.sdk.robot.model.RobotMsgType}
425  * @param content 消息内容,如果消息类型是{@link com.netease.nimlib.sdk.robot.model.RobotMsgType#TEXT},必须传入说话内容
426  * @param target 如果消息类型是{@link com.netease.nimlib.sdk.robot.model.RobotMsgType#LINK}, 必须传入跳转目标
427  * @param params 如果消息类型是{@link com.netease.nimlib.sdk.robot.model.RobotMsgType#LINK}时,可能需要传入参数
428  * @return 机器人消息
429  */
430  public static ChatRoomMessage createRobotMessage(String roomId, String robotAccount, String text, String type, String content, String target, String params) {
431  if (TextUtils.isEmpty(type) || TextUtils.isEmpty(robotAccount)) {
432  throw new IllegalArgumentException("Invalid param, type and robot account should not be null");
433  }
434 
435  if (type.equals(RobotMsgType.TEXT) && content == null) {
436  throw new IllegalArgumentException("Invalid param, content should not be null");
437  } else if (type.equals(RobotMsgType.LINK) && TextUtils.isEmpty(target)) {
438  throw new IllegalArgumentException("Invalid param, target should not be null");
439  }
440 
441  ChatRoomMessageImpl msg = initSendMessage(roomId);
442  msg.setMsgType(MsgTypeEnum.robot.getValue());
443 
444  // build attachment
445  RobotAttachment robotAttachment = new RobotAttachment();
446  robotAttachment.initSend(robotAccount, type, content, target, params);
447  msg.setAttachment(robotAttachment);
448  msg.setContent(text); // 文案显示用,便于全文检索等
449 
450  return msg;
451  }
452 
453  /**
454  * 创建一条空消息,仅设置了房间ID以及时间点,用于记录查询
455  *
456  * @param time 查询的时间起点信息
457  * @return 空消息
458  */
459  public static ChatRoomMessage createEmptyChatRoomMessage(String roomId, long time) {
460  ChatRoomMessageImpl msg = new ChatRoomMessageImpl();
461  msg.setSessionId(roomId);
462  msg.setSessionType(SessionTypeEnum.ChatRoom);
463  msg.setTime(time);
464 
465  return msg;
466  }
467 
468  private final static ChatRoomMessageImpl initSendMessage(String roomId) {
469  ChatRoomMessageImpl msg = new ChatRoomMessageImpl();
470  msg.setUuid(StringUtil.get32UUID());
471  msg.setSessionId(roomId);
472  msg.setFromAccount(SDKCacheUI.getChatRoomAccount());
473  msg.setDirect(MsgDirectionEnum.Out);
474  msg.setStatus(MsgStatusEnum.sending);
475  msg.setSessionType(SessionTypeEnum.ChatRoom);
476  msg.setTime(NtpTimeUtil.getServerNow());
477 
478  return msg;
479  }
480 }
static ChatRoomMessage createChatRoomSpatialLocationTextMessage(String roomId, String text, Double x, Double y, Double z)
创建普通文本消息
static ChatRoomMessage createChatRoomTextMessage(String roomId, String text)
创建普通文本消息
static ChatRoomMessage createChatRoomVideoMessage(String roomId, File file, long duration, int width, int height, String displayName, String nosTokenSceneKey)
创建一条视频消息 并指定视频文件上传时使用的 nos scene
static ChatRoomMessage createChatRoomCustomMessage(String roomId, MsgAttachment attachment, String nosTokenScene)
创建自定义消息 另外指定指定文件上传(如果有)时使用的 nos scene
.annotation.NonNull static FileAttachment createFileAttachment(File file, String displayName, String nosTokenSceneKey)
创建文件附件。用于上传文件。
static ChatRoomMessage createChatRoomImageMessage(Context context, String roomId, Uri uri, String displayName)
创建一条图片消息
static ChatRoomMessage createChatRoomAudioMessage(String roomId, File file, long duration, String nosTokenSceneKey)
创建一条音频消息 并指定音频文件上传时使用的 nos scene
static ChatRoomMessage createChatRoomImageMessage(Context context, String roomId, Uri uri, String displayName, String nosTokenSceneKey)
创建一条图片消息 并指定图片上传时使用的 nos scene
.annotation.NonNull static VideoAttachment createVideoAttachment(File file, long duration, int width, int height, String displayName, String nosTokenSceneKey)
创建视频附件。用于上传视频文件。
云信 IM 消息构造器,提供构建各类型消息的接口。
带有文件的附件类型的基类 描述文件的相关信息
消息本身发送/接收状态,附件状态见AttachStatusEnum
static ChatRoomMessage createChatRoomImageMessage(String roomId, File file, String displayName, String nosTokenSceneKey)
创建一条图片消息 并指定图片上传时使用的 nos scene
static ChatRoomMessage createChatRoomFileMessage(String roomId, File file, String displayName)
创建一条文件消息
static ChatRoomMessage createTipMessage(String roomId)
创建一条提醒消息
static ChatRoomMessage createChatRoomVideoMessage(String roomId, File file, long duration, int width, int height, String displayName)
创建一条视频消息
.annotation.NonNull static AudioAttachment createAudioAttachment(File file, long duration, String nosTokenSceneKey)
创建音频附件。用于上传音频文件。
.annotation.NonNull static ImageAttachment createImageAttachment(File file, String displayName, String nosTokenSceneKey)
创建图片附件,用于上传图片文件。
void initSend(String robotAccount, String type, String content, String target, String params)
String getThumbPathForSave()
获取用于保存缩略图文件的位置
static ChatRoomMessage createChatRoomFileMessage(Context context, String roomId, Uri uri, String displayName, String nosTokenSceneKey)
创建一条文件消息 并指定文件上传时使用的 nos scene
static ChatRoomMessage createChatRoomVideoMessage(Context context, String roomId, Uri uri, long duration, int width, int height, String displayName)
创建一条视频消息
void setAddress(String address)
设置地理位置描述信息
static ChatRoomMessage createEmptyChatRoomMessage(String roomId, long time)
创建一条空消息,仅设置了房间ID以及时间点,用于记录查询
static ChatRoomMessage createChatRoomCustomMessage(String roomId, MsgAttachment attachment)
创建自定义消息
static ChatRoomMessage createChatRoomAudioMessage(String roomId, File file, long duration)
创建一条音频消息
static ChatRoomMessage createChatRoomLocationMessage(String roomId, double lat, double lng, String addr)
创建一条地理位置信息
static ChatRoomMessage createChatRoomFileMessage(String roomId, File file, String displayName, String nosTokenSceneKey)
创建一条文件消息 并指定文件上传时使用的 nos scene
static ChatRoomMessage createChatRoomFileMessage(Context context, String roomId, Uri uri, String displayName)
创建一条文件消息 并指定文件上传时使用的 nos scene
static ChatRoomMessage createChatRoomAudioMessage(Context context, String roomId, Uri uri, long duration, String nosTokenSceneKey)
创建一条音频消息 并指定音频文件上传时使用的 nos scene
static ChatRoomMessage createRobotMessage(String roomId, String robotAccount, String text, String type, String content, String target, String params)
static ChatRoomMessage createChatRoomImageMessage(String roomId, File file, String displayName)
创建一条图片消息
static ChatRoomMessage createChatRoomAudioMessage(Context context, String roomId, Uri uri, long duration)
创建一条音频消息