The AppKey of you application.
Persistent connection address for the chat room. It is recommended to get the address of the chat room using the server API.
The avatar displayed after joining the chat room, if it is not configured and the user profile is hosted in NOS, then use the avatar in the user profile.
Extension field, the member information obtained in getChatroomMembers
JSON
format. For data other than JSON
format, the web client will receive the data but will be ignored by other clients.Extension field. In the onmsgs callback, if attach.type === 'memberEnter'
, attach.custom
is the chatroomEnterCustom
set during login
JSON
format. For data other than JSON
format, the web client will receive the data but will be ignored by other clients.// User A logs in
Chatroom.getInstance({
"account": "A",
"chatroomEnterCustom": "{'enterCustom': 'enterCustom'}"
})
// Logged-in User B gets notified by onmsgs
Chatroom.getInstance({
"account": "B",
"onmsgs": function(msg) {
if (msg.type === 'notification' && msg.attach.type === 'memberEnter') {
// {'enterCustom': 'enterCustom'}
console.log(msg.attach.custom)
}
}
})
Chat room ID
The nickname displayed after joining the chat room, if it is not configured and the user profile is hosted in NOS, then use the nickname in the user profile. If it is an anonymous login, this parameter is required
Custom client type, set an integer greater than 0
Note: The default client types are only Web, PC, AOS, and iOS. If you want to distinguish more types, such as WeChat Mini Program and other environments, they can use this field to map the values.
Client custom tag. Up to 32 characters
Note: This field is often used during login. Get notified when the account is logged in on other devices. You can configure a custom setting.
Specify whether to print the debugging log.. The default value is false.
Distance of the subscribed message
Whether to log in in anonymous mode The default value is false
Coordinate X, optional, only for location messages
Coordinate Y, optional, only for location messages
Coordinate z, optional, only for location messages
Log level, the default is off and no log is output.
Authentication method for logging in to a chat room (default value: 0):
Extension field for login
Note: the extension is synced with the app server, and will not be synchronized to other devices.
Whether to enable automatic reconnection. default value: true
NOS file storage global setting, default value: chatroom
The NOS storage global setting, the validity duration of storage. The default value Infinity must not be less than one day in seconds
Tag expression. Indicates which tagged users should the notifications for login and logout be broadcast to.
If unspecified, the server will automatically generate a tag expression according to NIMChatroomGetInstanceOptions.tags.
The generation rule is to combine all the tags in the and
keyword. Only users who have all the tags can receive the notifications for joining and leaving the chat room.
Whether to enable quick automatic reconnection. default value: false. If the value is set to true, NIM SDK will monitor the browser's offline and online events to detect network disconnection and recovery, and will implement corresponding disconnection and reconnection strategies.
The maximum number of times the SDK tries to reconnect. If the attempts exceed the maximum number, the SDK will stop reconnecting.
Whether to use the secure mode
In secure mode, a connection will be established with the server using HTTPS protocol, and in non-secure mode, a connection will be established with the server using HTTP protocol, the default value is true.
The number of concurrent socket connections.
Supported since v9.12.0 The maximum number of Socket concurrent connections. Valid values: an integer between 1 and 3. The default value is 1, no concurrent connections are supported. If you need more Socket connections, you can set this parameter.
tags
is used to identify which tags the persistent connection of this login belongs to. It is a JSON array. The same persistent connection can support up to 10 tags. Each tag can have a maximum of 32 characters, such as: ["abc", "def"]The login credentials of the account, use the token for verification when initializing the connection or reconnecting. No token is required for anonymous logins
Whether to perform additional processing on the log, such as log storage, log reporting, etc., this function will intercept the parameters of the console log for use Whether perform additional processing on the log, such as log storage, log reporting, etc.
This function will intercept the parameters of the SDK log for use.
const logs = []
setInterval(() => {
if (logs.length > 0) {
//Every 2 minutes, upload the logs to your app server
//...
//Clear logs
logs = []
}
}, 120000)
Chatroom.getInstance({
logFunc: {
log: function (data) {
logs.push(`log: ${data}`)
},
warn: function (data) {
logs.push(`warn: ${data}`)
},
info: function (data) {
logs.push(`info: ${data}`)
},
debug: function (data) {
logs.push(`debug: ${data}`)
},
error: function (data) {
logs.push(`error: ${data}`)
}
}
})
Call the server API, change the tag of a participant in the chat room Update the tags of all persistent connections of the specified account and trigger the callback.
Callback invoked when the SDK gets connected with the CommsEase server. Users can prompt the network status of the application in the interface using onwillreconnect, onconnect, ondisconnect and other callbacks
Chatroom.getInstance({
onconnect: function () {
showToast('connected')
}
})
Connection ID of the current login
Country
Client custom tag, multi-device synchronous field when logging in, up to 32 characters
IP address
Device ID of the last login
port
The callback invoked when the SDK is disconnected from the CommsEase server. Users can prompt the network status of the application in the interface using onwillreconnect, onconnect, ondisconnect and other callback functions
Chatroom.getInstance({
ondisconnect: function (res) {
showToast('Disconnected from the server')
}
})
Hook function-receiving a message in the chat room
The callback invoked when the SDK are connecting to the CommsEase server. Users can prompt the network status of the application in the interface using onwillreconnect, onconnect, ondisconnect and other callback functions
The interval for retries
Number of retries
Account ID, unique within the app.
Anonymous mode
Associated function