apply Gaussian blurring
Gaussian Blur Radius
Gaussian fuzzy standard deviation, cannot be less than 0
original URL to the image stored on NOS
URL to the image
The creator can close the chat room by calling this interface. All online members will be forcibly kicked. The server API:
After logging out of IM using the disconnect method, you can call connect to log in again. After calling getInstance, a persistent connection will be established automatically without calling connect.
chatroom.disconnect({
done: function() {
chatroom.connect()
}
})
Crop an image
Height
original URL to the image stored on NOS
Width
X coordinate, must be an integer
Y coordinate, must be an integer
URL to the image
Get the authentication token of the shortened URL.
URL to a file
full accessible URL
Disconnect from Chatroom, and destroy the Chatroom instance. If the instance is destroyed, you cannot call connect to reconnect to the chat room.
Disconnect from Chatroom, but do not destroy the Chatroom instance. You can call connect to connect again
Get the properties of a chat room. The server API:
Query the number of online users with a specified tag
Get the list of members in a chat room.
Get the members of a chat room by tag
Get the member information in a chat room. Get up to 20 accounts each time
Retrieve the message history of a chat room..
Limit, default value: 100
Message types. All types of messages by default
timestamp in milliseconds. If unspecified or 0, the value will be affected by reverse
Retrieve the message history of a chat room by tag.
start time
Limit on quantity. Default value: 100
The default value is 0.
Tags ['tag1', 'tag2', 'tag3']
End time
Message types
Callback
Get the authentication token of the shortened URL to get the file.
URL to a file
full accessible URL
Shortened URL to full URL
interlace image
original URL to the image stored on NOS
URL to the image
Remove a member from the chat room.
Log out
Note: For SDK earlier than v9.6.0, it is recommended to logout first and disconnect/destroy to fully exit the chat room.. SDK v9.6.0 and later do not need to call this API, it will be called automatically before disconnect/destroy.
Add a member to the blocklist
account
Extension field. The value of attach.custom
in notifications received by the members.
true
: to add, false
: to remove
callback for the result
There are 6 types of roles in the chat room:
account
Extension field. The value of attach.custom
in notifications received by the members.
true
: to add, false
: to remove
Level, default value: 0
callback for the result
Add a member to the list of muted members
account
Extension field. The value of attach.custom
in notifications received by the members.
true
: to add, false
: to remove
callback for the result
Grant the membership to a user. Members in the chat room will receive a notification message whose attach.type is one of the following:
There are 6 types of roles in the chat room:
account
Extension field. The value of attach.custom
in notifications received by the members.
the role to be assigned. If the role of a member does not belong to one of the following roles, the user is a regular member.
'manager'
(administrator)'common'
(regular)'black'
(added in the blocklist)'mute'
(added to the list of muted members)true
: to add, false
: to remove
callback for the result
There are 6 types of roles in the chat room:
account
Extension field. The value of attach.custom
in notifications received by the members.
true
: to add, false
: to remove
callback for the result
Get the first element of the queue. The return data is the third parameter of the callback
UniqKey of the element, up to 128 bytes
content in the element, up to 4096 bytes
Upload and preview files. Send a file message by calling the method.
Process an image
This method receives a set of image operations, and processes the images in order of operations. The optional operations include:
For the parameters required for each operation, see the above methods. In addition to the parameters listed in the above methods, each operation needs to provide the operation types:
// Rotate after cropping
var url = 'http://nim.nos.netease.com/MTAxMTAwMg==/bmltYV8xNDc5OTNfMTQ0MzE0NTgyNDI0M184YjFkYTMwMS02NjcxLTRiYjktYTUwZC04ZTVlZjZlNzZjMzA=';
nim.processImage({
url: url,
ops: [
{
type: 'crop',
x: 100,
y: 0,
width: 250,
height: 250,
},
{
type: 'thumbnail',
mode: 'cover',
width: 80,
height: 80
}
],
done: processImageDone
});
function processImageDone(error, obj) {
console.log('Processing the image' + (!error?'success':'failure'), error, obj);
}
Operation sequence for image processing. For specific format, see the previous interfaces for images
similar effect
[ { type: 'crop', x: 100, y: 0, width: 250, height: 250, }, { type: 'thumbnail', mode: 'cover', width: 80, height: 80 } ]
URL to the image
Modify the image quality
Image quality, must be an integer, value range: 0-100
original URL to the image stored on NOS
URL to the image
Update multiple elements in a queue. If needNotify is set to true, all online users will receive the following notification. If needNotify is set to false, no users receive updates
update multiple key-value pairs of elements at a time, key and value points to elementKey and elementValue. elementKey can have 128 bytes and elementValue can have 4096 bytes. Up to 100 pairs can be updated at a time.
custom field in the notification object, up to 2048
Callback for the result
Clear a queue. Only regular members of the chat room have permission to clear the queue. After the queue is cleared, all online users will receive the following notification:
Get the queue of a chat room queue
Add or update new elements in the queue. If elementKey already exists, update the element, otherwise insert a new element at the end of the queue. After the operation, all online users will receive the following notification message:
Optional parameter, the account to which elements belong. By default, the parameter is unspecified, the elements belongs to the current user. Administrators can specify the account to which the elements belong.
UniqKey of the new element, up to 128 bytes
Content in the new element, up to 4096 bytes
Optional, the default value false is used if unspecified. Whether the element is deleted when the account who submits the element gets disconnected or leaves the chat room.
callback for the result
Delete an element in the queue. After the operation, all online users will receive the following notification message:
The UniqKey of the element to be taken, An empty value indicates the first element will be taken.
callback for the result
UniqKey of the element, up to 128 bytes
content in the element, up to 4096 bytes
Rotate an image
Rotation angle
original URL to the image stored on NOS
URL to the image
You can call this API for custom messages, such as rock-paper-scissors and dice rolling.
This interface returns the message body in the sending state, and the sent message body needs to be obtained by passing options.done.
Calling this API can trigger:
chatroom.sendCustomMsg({
//The recipient receives the message using onMsg
//if msg.type === 'custom', the recipient reads msg.content and then calls the business code
content: JSON.stringify({type: 1}),
done: function(err, msg) {
if (err) {
console.log('Failed to send the message', err)
} else {
console.log('Message sent: ', msg)
}
}
})
Calling this API can trigger:
chatroom.sendFile({
type: 'image',
fileInput: 'domId',
done: function(err, msg) {
if (err) {
console.log('Failed to send the message', err)
} else {
console.log('Message sent: ', msg)
}
}
})
chatroom.previewFile({
type: 'image',
fileInput: fileInput,
uploadprogress: function(obj) {
console.log('Total size of a file: ' + obj.total + 'bytes');
console.log('Size of uploaded data: ' + obj.loaded + 'bytes');
console.log('Upload progress: ' + obj.percentage);
console.log('Upload progress in percentage: ' + obj.percentageText);
},
done: function(error, file) {
console.log('Uploading the image' + (!error?'success':'failure'));
// show file to the user
if (!error) {
var msg = chatroom.sendFile({
file: file,
done: sendMsgDone
});
console.log('Sending the image message, id=' + msg.idClient);
pushMsg(msg);
}
}
})
let message = chatroom.sendFile({
type: 'image',
fileInput: 'domId',
done: function(err, obj) {
if (err) {
console.log('Failed to send the message', err)
// Resend the message. When the file upload fails, the msg of the obj parameter contains the message body, and in other cases, the obj is the message body.
setTimeout(function () {
resendMessage(obj.msg ? obj.msg : obj)
}, 3000)
} else {
console.log('Message sent: ', obj)
}
}
})
// Get the idClient for rendering before uploading
console.log(message.idClient)
// Resend the message
function resendMessage(oldMessage) {
nim.sendFile(Object.assign(oldMessage, {
type: 'image',
fileInput: 'domId',
resend: true, // Note that the resend is marked as true, so that the idClient in oldMessage can be used.
done: function(err, obj) {
if (err) {
console.log('Failed to send the message', err)
} else {
console.log('Message sent: ', obj)
}
}
}))
}
Send a location message
This interface returns the message body in the sending state, and the sent message body needs to be obtained by passing options.done.
Calling this API can trigger:
chatroom.sendGeo({
//The recipient receives the message using onMsg
//if msg.type === 'geo', the recipient reads msg.geo, and then calls the business code
geo: {
lng: 116.3833,
lat: 39.9167,
title: 'Beijing'
},
done: function(err, msg) {
if (err) {
console.log('Failed to send the message', err)
} else {
console.log('Message sent: ', msg)
}
}
})
Send a text message
This interface returns the message body in the sending state, and the sent message body needs to be obtained by passing options.done.
Calling this API can trigger:
chatroom.sendText({
text: 'hello',
done: function(err, msg) {
if (err) {
console.log('Failed to send the message', err)
} else {
console.log('Message sent: ', msg)
}
}
})
Sending an alert Alerts are sent for notifications in a conversation. Typical use cases include welcome messages when joining a group or tips when hitting keywords for moderation in chats.
This interface returns the message body in the sending state, and the sent message body needs to be obtained by passing options.done.
Calling this API can trigger:
chatroom.sendTipMsg({
//The recipient receives the message using onMsg
//if msg.type === 'tip', the recipient reads msg.tip, and then calls the business code
tip: 'tip content',
done: function(err, msg) {
if (err) {
console.log('Failed to send the message', err)
} else {
console.log('Message sent: ', msg)
}
}
})
Remove the metadata of an image
Generate the thumbnails of an image
'cover'
: The original image is scaled in proportion, one side of the thumbnail is equal to the requested size, and the other side is larger than the requested size, that is, the thumbnail can just cover the rectangle with the size of width*height'contain'
: The original image is proportional to the thumbnail, one side of the thumbnail is equal to the requested size, and the other side is larger than the requested size, that is, a rectangle with a size of width*height can just cover the thumbnail'crop'
: First get the thumbnail based on the original image proportionally so that one side is equal to the requested size and the other side is larger than the requested size, and then crop the side larger than the requested size so that the final image size is exactly equal to the requested size (Note: the crop
mode does not support thumbnails to GIFs)'crop'
mode, parameters axis.x or axis.y can be used to control the position of the last cropping step.coordinates for cropping
Y coordinate, must be an integer
Y coordinate, must be an integer
Height of a thumbnail
original URL to the image stored on NOS
Width of a thumbnail
URL to the image
Update the chat room profile. The server API:
Business ID for moderation
Chat room profile to be updated
Announcement in a chat room
URL of a live streaming
Extension field
The name of a chat room
Permission for queue management: 0: all members have the permission to change the queue. 1: Only the owner and administrators can change the queue.
extension field for notifications
Whether the notification is required
callback for the result
Temporarily mute a member in a chat room. If needNotify === true, the members will receive the notification of attach.type === addTempMute
account
extension field of notifications
Mute duration in seconds. A value of 0 indicates unmuting
Whether a notification is required
callback
Update coordinates
Update the profile of the current user in a chat room
Temporarily mute a member based on the tag. If needNotify === true, the members will receive the notification of attach.type === addTempMuteTag
extension field of the notification object
The mute duration in seconds. A value of 0 indicates unmuted
Whether a notification is required
target tags of notifications. Default value: options.tag
Tag for muting
callback
Update the tag for the current persistent connection. If you update the tags by calling Server API, tags associated with the current persistent connection.
extension field of notifications, JSON string is recommended.
Whether a notification is required the update, default value: false, The scope of target members is defined by notifyTargetTags (note that notifyTargetTags can be configured during the initialization of a chat room)
Tags for notifications, a tag expression used to send notifications for members with specific tags. For example, a member gets online or offline. If unspecified, all members will receive the notification.
Tags. Multiple tags are allowed. You can override the value by updates. Example, ["tag1", "tag2"];To delete the tags, leave the value empty. If an empty array is specified, the tags are used but belong to no categories.
callback for the result
Audio to text Note that this feature is only available in NIM. Chat room has not yet implemented this feature.