Skip to content

Commit

Permalink
modify
Browse files Browse the repository at this point in the history
  • Loading branch information
haoxiuwen committed Oct 11, 2024
1 parent 3f9f344 commit 4322081
Show file tree
Hide file tree
Showing 7 changed files with 22 additions and 33 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -344,8 +344,6 @@ MessageListener msgListener = new MessageListener()

### Send a customized message

Custom messages are self-defined key-value pairs that include the message type and the message content.

The following code example shows how to create and send a customized message:

```java
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ After logging in to Agora Chat, users can send the following types of messages t
- Attachment messages, including image, voice, video, and file messages.
- Location messages.
- CMD messages.
- Extended messages.
- Custom messages.

In high-concurrency scenarios, you can set a certain message type or messages from a chat room member as high, normal, or low. In this case, low-priority messages are dropped first to reserve resources for the high-priority ones (e.g. gifts and announcements) when the server is overloaded. This ensures that the high-priority messages can be dealt with first when loads of messages are being sent in high concurrency or high frequency. Note that this feature can increase the delivery reliability of high-priority messages, but cannot guarantee the deliveries. Even high-priorities messages can be dropped when the server load goes too high.
Expand Down Expand Up @@ -89,7 +88,7 @@ ChatMessage fileMsg = ChatMessage.createFileSendMessage(
fileSize: fileSize,
);
// Creates a location message. You need to set the longitude and latitude information of the location, as well as the name of the location.
// To send a location message, you need to integrate a third-party map service provider to get the longitude and latitude information of the location. When the recipient receives the location information, the service provider renders the location on the map according to the longitude and latitude information.
// To send a location message, you need to integrate a third-party map service to get the longitude and latitude information of the location. When the recipient receives the location information, the service renders the location on the map according to the longitude and latitude information.
double latitude = 114.78;
double longitude = 39.89;
String address = "darwin";
Expand Down Expand Up @@ -201,7 +200,7 @@ When a voice message is received, the SDK automatically downloads the audio file

For image and video messages, the SDK automatically generates a thumbnail when you create the message. When an image or video message is received, the SDK automatically downloads the thumbnail. To manually download the attachment files, follow the steps:

1. Set `isAutoDownloadThumbnail` as true when initializing the SDK.
1. Set `isAutoDownloadThumbnail` as `false` when initializing the SDK.

```dart
ChatOptions options = ChatOptions(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,7 @@ AgoraChatMessage *message = [[AgoraChatMessage alloc] initWithConversationID:toC
body:body
ext:messageExt];
message.chatType = AgoraChatTypeChat;
// Set the chat type as Group chat. You can also set is as chat (one-to-one chat) or chat room.
// Set the chat type as Group chat. You can also set it as chat (one-to-one chat) or chat room.
// message.chatType = AgoraChatTypeGroupChat;
// Sends the message
[[AgoraChatClient sharedClient].chatManager sendMessage:message
Expand Down Expand Up @@ -212,7 +212,7 @@ AgoraChatMessage *message = [[AgoraChatMessage alloc] initWithConversationID:toC
body:body
ext:messageExt];
message.chatType = AgoraChatTypeChat;
// Set the chat type as Group chat. You can also set is as chat (one-to-one chat) or chat room.
// Set the chat type as Group chat. You can also set it as chat (one-to-one chat) or chat room.
// message.chatType = AgoraChatTypeGroupChat;
// Sends the message
[[AgoraChatClient sharedClient].chatManager sendMessage:message
Expand All @@ -235,7 +235,7 @@ NSString *remotePath = body.remotePath;
NSString *thumbnailPath = body.thumbnailRemotePath;
// Retrieves the path of the video file on the local device.
NSString *localPath = body.localPath;
// Retrieves the thumbnail of the video file on the local deivce.
// Retrieves the thumbnail of the video file on the local device.
NSString *thumbnailLocalPath = body.thumbnailLocalPath;
```

Expand All @@ -245,15 +245,15 @@ Refer to the following code example to create, send, and receive a file message:

```objective-c
// Set fileData as the path of the file on the local device, and fileName the display name of the attachment file.
AgoraChatFileMessageBody *body = [[AgoraChatFileMessageBody initWithData:fileData
AgoraChatFileMessageBody *body = [AgoraChatFileMessageBody initWithData:fileData
displayName:fileName];
AgoraChatMessage *message = [[AgoraChatMessage alloc] initWithConversationID:toChatUsername
from:fromChatUsername
to:toChatUsername
body:body
ext:messageExt];
message.chatType = AgoraChatTypeChat;
// Set the chat type as Group chat. You can also set is as chat (one-to-one chat) or chat room.
// Set the chat type as Group chat. You can also set it as chat (one-to-one chat) or chat room.
// message.chatType = AgoraChatTypeGroupChat;
// Sends the message
[[AgoraChatClient sharedClient].chatManager sendMessage:message
Expand Down Expand Up @@ -294,7 +294,7 @@ AgoraChatMessage *message = [[AgoraChatMessage alloc] initWithConversationID:toC
body:body
ext:messageExt];
message.chatType = AgoraChatTypeChat;
// Set the chat type as Group chat. You can also set is as chat (one-to-one chat) or chat room.
// Set the chat type as Group chat. You can also set it as chat (one-to-one chat) or chat room.
// message.chatType = AgoraChatTypeGroupChat;
// Sends the message
[[AgoraChatClient sharedClient].chatManager sendMessage:message
Expand All @@ -317,15 +317,15 @@ AgoraChatMessage *message = [[AgoraChatMessage alloc] initWithConversationID:toC
body:body
ext:messageExt];
message.chatType = AgoraChatTypeChat;
// Set the chat type as Group chat. You can also set is as chat (one-to-one chat) or chat room.
// Set the chat type as Group chat. You can also set it as chat (one-to-one chat) or chat room.
// message.chatType = AgoraChatTypeGroupChat;
// Sends the message
[[AgoraChatClient sharedClient].chatManager sendMessage:message
progress:nil
completion:nil];
```

To notify the recipient that a CMD message is received, use a seperate delegate so that users can deal with the message differently.
To notify the recipient that a CMD message is received, use a separate delegate so that users can deal with the message differently.

```objective-c
// Occurs when the CMD message is received.
Expand All @@ -339,8 +339,6 @@ To notify the recipient that a CMD message is received, use a seperate delegate

### Send a customized message

Custom messages are self-defined key-value pairs that include the message type and the message content.

The following code example shows how to create and send a customized message:

```objective-c
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ After logging in to Agora Chat, users can send the following types of messages t
- Attachment messages, including image, voice, video, and file messages.
- Location messages.
- CMD messages.
- Extended messages.
- Custom messages.

In high-concurrency scenarios, you can set a certain message type or messages from a chat room member as high, normal, or low. In this case, low-priority messages are dropped first to reserve resources for the high-priority ones (e.g. gifts and announcements) when the server is overloaded. This ensures that the high-priority messages can be dealt with first when loads of messages are being sent in high concurrency or high frequency. Note that this feature can increase the delivery reliability of high-priority messages, but cannot guarantee the deliveries. Even high-priorities messages can be dropped when the server load goes too high.
Expand All @@ -12,7 +11,7 @@ This page shows how to implement sending and receiving these messages using the

## Understand the tech

The Agora Chat SDK uses the `ChatMessage` and `ChatMessage` classes to send, receive, and withdraw messages.
The Agora Chat SDK uses the `ChatManager` and `ChatMessage` classes to send, receive, and withdraw messages.

The process of sending and receiving a message is as follows:

Expand Down Expand Up @@ -206,7 +205,7 @@ class ChatMessageEvent implements ChatMessageEventListener {
console.log(`onConversationRead: `, from, to);
}
}
// Listen for the mesage event.
// Listen for the message event.
const listener = new ChatMessageEvent();
ChatClient.getInstance().chatManager.addMessageListener(listener);
// Remove the specified message listener.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ After logging in to Agora Chat, users can send the following types of messages t
- Attachment messages, including image, voice, video, and file messages.
- Location messages.
- CMD messages.
- Extended messages.
- Custom messages.

In high-concurrency scenarios, you can set a certain message type or messages from a chat room member as high, normal, or low. In this case, low-priority messages are dropped first to reserve resources for the high-priority ones (e.g. gifts and announcements) when the server is overloaded. This ensures that the high-priority messages can be dealt with first when loads of messages are being sent in high concurrency or high frequency. Note that this feature can increase the delivery reliability of high-priority messages, but cannot guarantee the deliveries. Even high-priorities messages can be dropped when the server load goes too high.
Expand All @@ -18,7 +17,7 @@ The process of sending and receiving a message is as follows:

1. The message sender creates a text, file, or attachment message using the corresponding `Create` method.
2. The message sender calls `SendMessage` to send the message.
3. The message recipient calls `AddChatManagerDelegate` to listens for message events and receives the message in the `OnMessageReceived` callback.
3. The message recipient calls `AddChatManagerDelegate` to listen for message events and receive the message in the `OnMessageReceived` callback.

## Prerequistes

Expand All @@ -42,7 +41,7 @@ Message msg = Message.CreateTextSendMessage(conversationId, content);
// Set `MessageType` in `Message` as `Chat`, `Group`, or `Room` for one-to-one chat, group chat, or room chat.
msg.MessageType = MessageType.Group;

// Set the priority of chat room messages. The default priority is `Normal`, indicating the normal priority.
// Set the priority of chat room messages. The default priority is `RoomMessagePriority.Normal`, indicating the normal priority.
// msg.MessageType = MessageType.Room;
// msg.SetRoomMessagePriority(RoomMessagePriority.High);
Expand Down Expand Up @@ -113,7 +112,7 @@ void OnMessagesRecalled(List<Message> messages);

### Send and receive an attachment message

Voice, image, video, and file messages are issentially attachment messages. This section introduces how to send these types of messages.
Voice, image, video, and file messages are essentially attachment messages. This section introduces how to send these types of messages.

#### Send and receive a voice message

Expand Down Expand Up @@ -163,14 +162,14 @@ else {

#### Send and receive an image message

By default, the SDK compresses the image file before sending it. To send the originial file, you can set `original` as `true`.
By default, the SDK compresses the image file before sending it. To send the original file, you can set `original` as `true`.

Refer to the following code example to create and send an image message:

```C#
// Create SendMessage to send the image message.
// Set `localPath` as the path of the image file on the local device, `displayName` as the display name of the message, `fileSize` as the size of the image file, `width` as the width (in pixels) of the thumbnail, and `height` as the height (in pixels) of the thumbnail.
// `orignial` indicates whether to send the original image file. The default value is `false`. By default, the SDK compresses image files the exceeds 100 KB and sends the thumbnail. To send the originial image, set this parameter as `true`.
// `original` indicates whether to send the original image file. The default value is `false`. By default, the SDK compresses image files that exceeds 100 KB and sends the thumbnail. To send the original image, set this parameter as `true`.
Message msg = Message.CreateImageSendMessage(toChatUsername,localPath, displayName, fileSize, original, width , height);
// Set the message type using the `MessageType` attribute in `Message`.
// You can set `MessageType` as `Chat`, `Group`, or `Room`, which indicates whether to send the message to a peer user, a chat group, or a chat room.
Expand Down Expand Up @@ -244,7 +243,7 @@ If you do not want the SDK to automatically download the video thumbnail, set `O
To download the actual video file, call `SDKClient.Instance.ChatManager.DownloadAttachment`, and get the path of the video file from the `LocalPath` member in `msg.Body`.

```C#
// When the recipent receives a video message, the SDK downloads and then open the video file.
// When the recipient receives a video message, the SDK downloads and then open the video file.
SDKClient.Instance.ChatManager.DownloadAttachment("Message ID", new CallBack(
onSuccess: () => {
Debug.Log($"Attachment download succeeds.");
Expand Down Expand Up @@ -350,7 +349,7 @@ SDKClient.Instance.ChatManager.SendMessage(ref msg, new CallBack(
));
```

To notify the recipient that a CMD message is received, use a seperate delegate so that users can deal with the message differently.
To notify the recipient that a CMD message is received, use a separate delegate so that users can deal with the message differently.

```C#
// Inherit and instantiate `IChatManagerDelegate`.
Expand All @@ -373,8 +372,6 @@ SDKClient.Instance.ChatManager.AddChatManagerDelegate(adelegate);

### Send a customized message

Custom messages are self-defined key-value pairs that include the message type and the message content.

The following code example shows how to create and send a customized message:

```C#
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -92,9 +92,9 @@ When a message arrives, the recipient receives an `onXXXMessage` callback. Each
// Use `addEventHandler` to listen for callback events.
connection.addEventHandler("eventName",{
// Occurs when the app is connected.
onOpened: function (message) {},
onConnected: function (message) {},
// Occurs when the connection is lost.
onClosed: function (message) {},
onDisconnected: function (message) {},
// Occurs when the text message is received.
onTextMessage: function (message) {},
// Occurs when the image message is received.
Expand Down Expand Up @@ -174,7 +174,7 @@ connection.addEventHandler('MESSAGES',{
Voice, image, video, and file messages are essentially attachment messages.

When sending an attachment message, the SDK takes the following steps:
1. Uploads the attachment to the server and gets the information of the attachment file on the server
1. Uploads the attachment to the server and gets the information of the attachment file on the server.
2. Sends the attachment message, which contains the basic information of the message, and the path to the attachment file on the server.

For the attachment messages, you can upload the attachment to your server, instead of the Agora server, before sending an attachment message. In this case, you need to set the `useOwnUploadFun` parameter in the `connection` class to `true` during SDK initialization. For example, to send an image message, you can call `sendPrivateUrlImg` to pass in the image URL after uploading the image attachment.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -373,8 +373,6 @@ SDKClient.Instance.ChatManager.AddChatManagerDelegate(adelegate);

### Send a customized message

Custom messages are self-defined key-value pairs that include the message type and the message content.

The following code example shows how to create and send a customized message:

```C#
Expand Down

0 comments on commit 4322081

Please sign in to comment.