NIMSDK-AOS  10.9.76
V2NIMChatroomEnterParams.java
浏览该文件的文档.
1 package com.netease.nimlib.sdk.v2.chatroom.params;
2 
8 
9 import java.io.Serializable;
10 
11 /**
12  * 加入聊天室登录相关参数
13  */
14 public class V2NIMChatroomEnterParams implements Serializable {
15 
16  /**
17  * 是否匿名模式
18  * 匿名模式不能发消息, 只能收消息
19  */
20  private final boolean anonymousMode;
21 
22  /**
23  * 是否启用聊天室LBS
24  */
25  private final boolean enableLbs;
26 
27  /**
28  * 账号ID
29  * 如果是匿名, 可以不填,内部生成账号
30  * 规则:nimanon_ UUID.randomUUID().toString(), 建议全局缓存一个
31  * 否则必须是合法的账号
32  */
33 
34  private final String accountId;
35 
36  /**
37  * 静态token
38  * 快速使用接口, 方便用户使用,可以不填
39  */
40  private final String token;
41 
42 
43  /**
44  * 进入聊天室后显示的昵称
45  * 如果填写则使用填写的内容
46  * 否则使用账号对应相关信息
47  * 如果是匿名模式,默认昵称为账号名称
48  */
49  private final String roomNick;
50 
51  /**
52  * 进入聊天室后显示的头像
53  * 如果填写则使用填写的内容
54  * 否则使用账号对应相关信息
55  * 如果为匿名模式,默认头像为空,如果需要头像,上传可以采用:SDK-API存储服务设计文档 uploadFile
56  */
57  private final String roomAvatar;
58 
59  /**
60  * 进入方法超时时间
61  * 超过该时间如果没有进入成功, 则返回失败
62  */
63  private final int timeout;
64 
65  /**
66  * 聊天室登录相关信息
67  */
68  private final V2NIMChatroomLoginOption loginOption;
69 
70  /**
71  * 获取聊天室link链接地址, 两种获取途径
72  * 如果IM已经登录且在线, 可以采用V2NIMLoginService.getChatroomLinkAddress 方法获取(用IM的长连接发送 13-1)note:新增接口
73  * 由客户代理实现,请求业务服务器,由业务服务器请求云信OpenApi获得
74  */
75  private final V2NIMChatroomLinkProvider linkProvider;
76 
77  /**
78  * 用户扩展字段,建议使用json格式
79  */
80  private final String serverExtension;
81 
82  /**
83  * 通知扩展字段,进入聊天室通知开发者扩展字段
84  */
85  private final String notificationExtension;
86 
87  /**
88  * 进入聊天室标签信息配置
89  */
90  private final V2NIMChatroomTagConfig tagConfig;
91 
92  /**
93  * 进入聊天室空间位置信息配置
94  */
95  private final V2NIMChatroomLocationConfig locationConfig;
96 
97 
98  /**
99  * 用户资料反垃圾检测
100  * 如果不审核,该配置不需要配置
101  * 如果开启了安全通,默认采用安全通,该配置不需要配置
102  * 如果需要审核,且直接对接易盾,则配置该配置
103  */
104  private final V2NIMAntispamConfig antispamConfig;
105 
106  private V2NIMChatroomEnterParams() {
107  this(false, false, null, null, null, null, TIMEOUT_DEFAULT, null, null, null, null, null, null, null);
108  }
109 
110  public V2NIMChatroomEnterParams(boolean anonymousMode, boolean enableLbs, String accountId, String token, String roomNick, String roomAvatar, int timeout, V2NIMChatroomLoginOption loginOption, V2NIMChatroomLinkProvider linkProvider, String serverExtension, String notificationExtension, V2NIMChatroomTagConfig tagConfig, V2NIMChatroomLocationConfig locationConfig, V2NIMAntispamConfig antispamConfig) {
111  this.anonymousMode = anonymousMode;
112  this.enableLbs = enableLbs;
113  this.accountId = accountId;
114  this.token = token;
115  this.roomNick = roomNick;
116  this.roomAvatar = roomAvatar;
117  this.timeout = timeout;
118  this.loginOption = loginOption;
119  this.linkProvider = linkProvider;
120  this.serverExtension = serverExtension;
121  this.notificationExtension = notificationExtension;
122  this.tagConfig = tagConfig;
123  this.locationConfig = locationConfig;
124  this.antispamConfig = antispamConfig;
125  }
126  /**
127  * 获取是否匿名模式
128  * @return 是否匿名模式
129  */
130  public boolean isAnonymousMode() {
131  return anonymousMode;
132  }
133 
134  public boolean isEnableLbs() {
135  return enableLbs;
136  }
137 
138  /**
139  * 获取账号ID
140  * @return 账号ID
141  */
142  public String getAccountId() {
143  return accountId;
144  }
145  /**
146  * 获取静态token
147  * @return 静态token
148  */
149  public String getToken() {
150  return token;
151  }
152  /**
153  * 获取进入聊天室后显示的昵称
154  * @return 进入聊天室后显示的昵称
155  */
156  public String getRoomNick() {
157  return roomNick;
158  }
159  /**
160  * 获取进入聊天室后显示的头像
161  * @return 进入聊天室后显示的头像
162  */
163  public String getRoomAvatar() {
164  return roomAvatar;
165  }
166  /**
167  * 获取进入方法超时时间
168  * @return 进入方法超时时间
169  */
170  public int getTimeout() {
171  return timeout;
172  }
173  /**
174  * 获取聊天室登录相关信息
175  * @return 聊天室登录相关信息
176  */
178  if (loginOption == null) {
180  } else {
181  return loginOption;
182  }
183  }
184  /**
185  * 获取获取聊天室link链接地址, 两种获取途径
186  * @return 获取聊天室link链接地址, 两种获取途径
187  */
189  return linkProvider;
190  }
191  /**
192  * 获取用户扩展字段,建议使用json格式
193  * @return 用户扩展字段,建议使用json格式
194  */
195  public String getServerExtension() {
196  return serverExtension;
197  }
198  /**
199  * 获取通知扩展字段,进入聊天室通知开发者扩展字段
200  * @return 通知扩展字段,进入聊天室通知开发者扩展字段
201  */
202  public String getNotificationExtension() {
203  return notificationExtension;
204  }
205  /**
206  * 获取进入聊天室标签信息配置
207  * @return 进入聊天室标签信息配置
208  */
210  return tagConfig;
211  }
212  /**
213  * 获取进入聊天室空间位置信息配置
214  * @return 进入聊天室空间位置信息配置
215  */
217  return locationConfig;
218  }
219  /**
220  * 获取用户资料反垃圾检测
221  * @return 用户资料反垃圾检测
222  */
224  return antispamConfig;
225  }
226 
227  @Override
228  public String toString() {
229  return "V2NIMChatroomEnterParams{" +
230  "anonymousMode=" + anonymousMode +
231  ", enableLbs='" + enableLbs + '\'' +
232  ", accountId='" + accountId + '\'' +
233  ", token='" + token + '\'' +
234  ", roomNick='" + roomNick + '\'' +
235  ", roomAvatar='" + roomAvatar + '\'' +
236  ", timeout=" + timeout +
237  ", loginOption=" + loginOption +
238  ", linkProvider=" + linkProvider +
239  ", serverExtension='" + serverExtension + '\'' +
240  ", notificationExtension='" + notificationExtension + '\'' +
241  ", tagConfig=" + tagConfig + '\'' +
242  ", locationConfig=" + locationConfig + '\'' +
243  ", antispamConfig=" + antispamConfig + '\'' +
244  '}';
245  }
246 
247  private static final int TIMEOUT_DEFAULT = 60;
248 
249  /**
250  * {@link V2NIMChatroomEnterParams}构造器
251  */
252  public static final class V2NIMChatroomEnterParamsBuilder {
253 
254  /**
255  * 聊天室登录相关信息
256  */
257  private V2NIMChatroomLoginOption loginOption;
258  /**
259  * 获取聊天室link链接地址, 两种获取途径
260  * 如果IM已经登录且在线, 可以采用V2NIMLoginService.getChatroomLinkAddress 方法获取(用IM的长连接发送 13-1)note:新增接口
261  * 由客户代理实现,请求业务服务器,由业务服务器请求云信OpenApi获得
262  */
263  private final V2NIMChatroomLinkProvider linkProvider;
264  /**
265  * 是否匿名模式
266  * 匿名模式不能发消息, 只能收消息
267  */
268  private boolean anonymousMode;
269  /**
270  * 账号ID
271  */
272  private String accountId;
273  /**
274  * 静态token
275  */
276  private String token;
277  /**
278  * 进入聊天室后显示的昵称
279  */
280  private String roomNick;
281  /**
282  * 进入聊天室后显示的头像
283  */
284  private String roomAvatar;
285  /**
286  * 进入方法超时时间
287  */
288  private int timeout = TIMEOUT_DEFAULT;
289  /**
290  * 用户扩展字段,建议使用json格式
291  */
292  private String serverExtension;
293  /**
294  * 通知扩展字段,进入聊天室通知开发者扩展字段
295  */
296  private String notificationExtension;
297  /**
298  * 进入聊天室标签信息配置
299  */
300  private V2NIMChatroomTagConfig tagConfig;
301  /**
302  * 进入聊天室空间位置信息配置
303  */
304  private V2NIMChatroomLocationConfig locationConfig;
305  /**
306  * 用户资料反垃圾检测
307  */
308  private V2NIMAntispamConfig antispamConfig;
309  /**
310  * 是否启用聊天室LBS
311  */
312  private boolean enableLbs;
313 
314  private V2NIMChatroomEnterParamsBuilder(V2NIMChatroomLinkProvider linkProvider) {
315  this.linkProvider = linkProvider;
316  }
317 
318  /**
319  *
320  * @param linkProvider 获取聊天室link链接地址, 两种获取途径
321  * @return {@link V2NIMChatroomEnterParamsBuilder}
322  */
323  public static V2NIMChatroomEnterParamsBuilder builder(V2NIMChatroomLinkProvider linkProvider) {
324  return new V2NIMChatroomEnterParamsBuilder(linkProvider);
325  }
326 
327  /**
328  * 设置聊天室登录相关信息
329  * @param loginOption 聊天室登录相关信息
330  * @return {@link V2NIMChatroomEnterParamsBuilder}
331  */
332  public V2NIMChatroomEnterParamsBuilder withLoginOption(V2NIMChatroomLoginOption loginOption) {
333  this.loginOption = loginOption;
334  return this;
335  }
336 
337  /**
338  * 设置是否匿名模式
339  * @param anonymousMode 是否匿名模式
340  * @return {@link V2NIMChatroomEnterParamsBuilder}
341  */
342  public V2NIMChatroomEnterParamsBuilder withAnonymousMode(boolean anonymousMode) {
343  this.anonymousMode = anonymousMode;
344  return this;
345  }
346 
347  /**
348  * 设置是否启用聊天室LBS
349  * @param enableLbs 是否启用聊天室LBS
350  * @return {@link V2NIMChatroomEnterParamsBuilder}
351  */
352  public V2NIMChatroomEnterParamsBuilder withEnableLbs(boolean enableLbs) {
353  this.enableLbs = enableLbs;
354  return this;
355  }
356 
357  /**
358  * 设置账号ID
359  * @param accountId 账号ID
360  * @return {@link V2NIMChatroomEnterParamsBuilder}
361  */
362  public V2NIMChatroomEnterParamsBuilder withAccountId(String accountId) {
363  this.accountId = accountId;
364  return this;
365  }
366 
367  /**
368  * 设置静态token
369  * @param token 静态token
370  * @return {@link V2NIMChatroomEnterParamsBuilder}
371  */
372  public V2NIMChatroomEnterParamsBuilder withToken(String token) {
373  this.token = token;
374  return this;
375  }
376 
377  /**
378  * 设置进入聊天室后显示的昵称
379  * @param roomNick 进入聊天室后显示的昵称
380  * @return {@link V2NIMChatroomEnterParamsBuilder}
381  */
382  public V2NIMChatroomEnterParamsBuilder withRoomNick(String roomNick) {
383  this.roomNick = roomNick;
384  return this;
385  }
386 
387  /**
388  * 设置进入聊天室后显示的头像
389  * @param roomAvatar 进入聊天室后显示的头像
390  * @return {@link V2NIMChatroomEnterParamsBuilder}
391  */
392  public V2NIMChatroomEnterParamsBuilder withRoomAvatar(String roomAvatar) {
393  this.roomAvatar = roomAvatar;
394  return this;
395  }
396 
397  /**
398  * 设置进入方法超时时间
399  * @param timeout 进入方法超时时间
400  * @return {@link V2NIMChatroomEnterParamsBuilder}
401  */
402  public V2NIMChatroomEnterParamsBuilder withTimeout(int timeout) {
403  this.timeout = timeout;
404  return this;
405  }
406 
407  /**
408  * 设置用户扩展字段,建议使用json格式
409  * @param serverExtension 用户扩展字段,建议使用json格式
410  * @return {@link V2NIMChatroomEnterParamsBuilder}
411  */
412  public V2NIMChatroomEnterParamsBuilder withServerExtension(String serverExtension) {
413  this.serverExtension = serverExtension;
414  return this;
415  }
416 
417  /**
418  * 设置通知扩展字段,进入聊天室通知开发者扩展字段
419  * @param notificationExtension 通知扩展字段,进入聊天室通知开发者扩展字段
420  * @return {@link V2NIMChatroomEnterParamsBuilder}
421  */
422  public V2NIMChatroomEnterParamsBuilder withNotificationExtension(String notificationExtension) {
423  this.notificationExtension = notificationExtension;
424  return this;
425  }
426 
427  /**
428  * 设置进入聊天室标签信息配置
429  * @param tagConfig 进入聊天室标签信息配置
430  * @return {@link V2NIMChatroomEnterParamsBuilder}
431  */
432  public V2NIMChatroomEnterParamsBuilder withTagConfig(V2NIMChatroomTagConfig tagConfig) {
433  this.tagConfig = tagConfig;
434  return this;
435  }
436 
437  /**
438  * 设置进入聊天室空间位置信息配置
439  * @param locationConfig 进入聊天室空间位置信息配置
440  * @return {@link V2NIMChatroomEnterParamsBuilder}
441  */
442  public V2NIMChatroomEnterParamsBuilder withLocationConfig(V2NIMChatroomLocationConfig locationConfig) {
443  this.locationConfig = locationConfig;
444  return this;
445  }
446 
447  /**
448  * 设置用户资料反垃圾检测
449  * @param antispamConfig 用户资料反垃圾检测
450  * @return {@link V2NIMChatroomEnterParamsBuilder}
451  */
452  public V2NIMChatroomEnterParamsBuilder withAntispamConfig(V2NIMAntispamConfig antispamConfig) {
453  this.antispamConfig = antispamConfig;
454  return this;
455  }
456 
457  /**
458  * 构建{@link V2NIMChatroomEnterParams}
459  * @return {@link V2NIMChatroomEnterParams}
460  */
461  public V2NIMChatroomEnterParams build() {
462  return new V2NIMChatroomEnterParams(anonymousMode, enableLbs, accountId, token, roomNick, roomAvatar, timeout, loginOption, linkProvider, serverExtension, notificationExtension, tagConfig, locationConfig, antispamConfig);
463  }
464  }
465 }
String getNotificationExtension()
获取通知扩展字段,进入聊天室通知开发者扩展字段
V2NIMChatroomLoginOption getLoginOption()
获取聊天室登录相关信息
V2NIMChatroomLinkProvider getLinkProvider()
获取获取聊天室link链接地址, 两种获取途径
V2NIMChatroomLocationConfig getLocationConfig()
获取进入聊天室空间位置信息配置
V2NIMChatroomTagConfig getTagConfig()
获取进入聊天室标签信息配置
String getServerExtension()
获取用户扩展字段,建议使用json格式
V2NIMAntispamConfig getAntispamConfig()
获取用户资料反垃圾检测
V2NIMChatroomEnterParams(boolean anonymousMode, boolean enableLbs, String accountId, String token, String roomNick, String roomAvatar, int timeout, V2NIMChatroomLoginOption loginOption, V2NIMChatroomLinkProvider linkProvider, String serverExtension, String notificationExtension, V2NIMChatroomTagConfig tagConfig, V2NIMChatroomLocationConfig locationConfig, V2NIMAntispamConfig antispamConfig)