From 5efa36efb2af0ee1fb6ca3820fbc37b3dbc1b43d Mon Sep 17 00:00:00 2001 From: haoxiuwen Date: Mon, 25 Sep 2023 10:02:46 +0800 Subject: [PATCH] modify --- ...agora_chat_send_receive_message_android.md | 14 +++++----- ...agora_chat_send_receive_message_flutter.md | 6 ++--- .../agora_chat_send_receive_message_ios.md | 27 ++++++++++--------- .../agora_chat_send_receive_message_rn.md | 14 +++++----- .../agora_chat_send_receive_message_unity.md | 20 ++++++++------ .../agora_chat_send_receive_message_web.md | 8 +++--- ...agora_chat_send_receive_message_windows.md | 22 ++++++++------- 7 files changed, 61 insertions(+), 50 deletions(-) diff --git a/en-US/markdown/agora-chat/Develop/Messages/Send and Receive Messages/agora_chat_send_receive_message_android.md b/en-US/markdown/agora-chat/Develop/Messages/Send and Receive Messages/agora_chat_send_receive_message_android.md index 398e4e02151..9dfa38e30e0 100644 --- a/en-US/markdown/agora-chat/Develop/Messages/Send and Receive Messages/agora_chat_send_receive_message_android.md +++ b/en-US/markdown/agora-chat/Develop/Messages/Send and Receive Messages/agora_chat_send_receive_message_android.md @@ -35,17 +35,19 @@ This section shows how to implement sending and receiving the various types of m Use the `ChatMessage` class to create a text message, and send the message. ```java -// Call createTextSendMessage to create a text message. Set content as the content of the text message, and conversationId the user ID of the message recipient. +// Call createTextSendMessage to create a text message. +// Set `content` as the content of the text message. +// Set `conversationId` to the user ID of the peer user in one-to-one chat, group ID in group chat, and chat room ID in room chat. ChatMessage message = ChatMessage.createTextSendMessage(content, conversationId); -// 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. +// Set `ChatType` as `Chat`, `GroupChat`, or `ChatRoom` for one-to-one chat, group chat, or room chat. message.setChatType(ChatMessage.ChatType.GroupChat); - // Send the message + // Send the message. ChatClient.getInstance().chatManager().sendMessage(message); ``` ```java -// Calls setMessageStatusCallback to set the callback instance to get the status of messaging sending. You can update the status of messages in this callback, for example, adding a tip when the message sending fails. +// Call setMessageStatusCallback to set the callback instance to get the status of messaging sending. +// You can update the status of messages in this callback, for example, adding a tip when the message sending fails. message.setMessageStatusCallback(new CallBack() { @Override public void onSuccess() { @@ -74,7 +76,7 @@ sendMessage(message); You can use `MessageListener` to listen for message events. You can add multiple `MessageListener`s to listen for multiple events. When you no longer listen for an event, ensure that you remove the listener. -When a message arrives, the recipient receives an `onMessgesReceived` callback. Each callback contains one or more messages. You can traverse the message list, and parse and render these messages in this callback. +When a message arrives, the recipient receives an `onMessagesReceived` callback. Each callback contains one or more messages. You can traverse the message list, and parse and render these messages in this callback. ```java MessageListener msgListener = new MessageListener() { diff --git a/en-US/markdown/agora-chat/Develop/Messages/Send and Receive Messages/agora_chat_send_receive_message_flutter.md b/en-US/markdown/agora-chat/Develop/Messages/Send and Receive Messages/agora_chat_send_receive_message_flutter.md index df8da3b734d..8d800fb72f8 100644 --- a/en-US/markdown/agora-chat/Develop/Messages/Send and Receive Messages/agora_chat_send_receive_message_flutter.md +++ b/en-US/markdown/agora-chat/Develop/Messages/Send and Receive Messages/agora_chat_send_receive_message_flutter.md @@ -39,11 +39,11 @@ Follow the steps to create and send a message, and listen for the result of send ```dart // Sets the message type. Agora Chat supports 8 message types. MessageType messageType = MessageType.TXT; -// Sets the user ID of the recipient. +// Sets `targetId` to the user ID of the peer user in one-to-one chat, group ID in group chat, and chat room ID in room chat. String targetId = "tom"; -// Sets the chat type. You can set it as a peer user, chat group, or chat room. +// Sets `chatType` as `Chat`, `GroupChat`, or `ChatRoom` for one-to-one chat, group chat, or room chat. ChatType chatType = ChatType.Chat; -// Creates a message. For different message types, you need to set different parameters. +// Creates a message. Parameters vary with message types. // Creates a text message. ChatMessage msg = ChatMessage.createTxtSendMessage( targetId: targetId, diff --git a/en-US/markdown/agora-chat/Develop/Messages/Send and Receive Messages/agora_chat_send_receive_message_ios.md b/en-US/markdown/agora-chat/Develop/Messages/Send and Receive Messages/agora_chat_send_receive_message_ios.md index 06a9e6c6304..dd92fbc4873 100644 --- a/en-US/markdown/agora-chat/Develop/Messages/Send and Receive Messages/agora_chat_send_receive_message_ios.md +++ b/en-US/markdown/agora-chat/Develop/Messages/Send and Receive Messages/agora_chat_send_receive_message_ios.md @@ -35,19 +35,20 @@ This section shows how to implement sending and receiving the various types of m Use the `AgoraChatTextMessageBody` class to create a text message, and then send the message. ```objective-c -// Call initWithText to create a text message. Set content as the text content and toChatUsername to the username to whom you want to send this text message. -AgoraChatTextMessageBody *textMessageBody = [[AgoraChatTextMessageBody alloc] initWithText:content]; -AgoraChatMessage *message = [[AgoraChatMessage alloc] initWithConversationID:toChatUsername - from:fromChatUsername - to:toChatUsername - body:textMessageBody - ext:messageExt]; -// Set the chat type as Group chat. You can also set is as chat (one-to-one chat) or chat room. -// message.chatType = AgoraChatTypeGroupChat; -// Sends the message -[[AgoraChatClient sharedClient].chatManager sendMessage:message - progress:nil - completion:nil]; +// Call initWithText to create a text message. Set `content` to the text content. + AgoraChatTextMessageBody *textMessageBody = [[AgoraChatTextMessageBody alloc] initWithText:content]; + // Set `conversationId` to the user ID of the peer user in one-to-one chat, group ID in group chat, and chat room ID in room chat. + NSString* conversationId = @"remoteUserId"; + AgoraChatMessage *message = [[AgoraChatMessage alloc] initWithConversationID:conversationId + body:textMessageBody + ext:messageExt]; + // Set `message.chatType` to `AgoraChatTypeChat` for one-to-one chat, `AgoraChatTypeGroupChat` for group chat, and `AgoraChatTypeChatRoom` for room chat. + // The default value is `AgoraChatTypeChat`. + message.chatType = AgoraChatTypeChat; + // Send the message. + [[AgoraChatClient sharedClient].chatManager sendMessage:message + progress:nil + completion:nil]; ``` You can set the priority of chat room messages. diff --git a/en-US/markdown/agora-chat/Develop/Messages/Send and Receive Messages/agora_chat_send_receive_message_rn.md b/en-US/markdown/agora-chat/Develop/Messages/Send and Receive Messages/agora_chat_send_receive_message_rn.md index f424605d017..c0ef24bcc83 100644 --- a/en-US/markdown/agora-chat/Develop/Messages/Send and Receive Messages/agora_chat_send_receive_message_rn.md +++ b/en-US/markdown/agora-chat/Develop/Messages/Send and Receive Messages/agora_chat_send_receive_message_rn.md @@ -64,27 +64,27 @@ class ChatMessageCallback implements ChatMessageStatusCallback { .catch((reason) => { // The sending operation fails and the log is printed here. console.log("send message operation fail.", reason); - }); + }) + }; ``` Use the `ChatMessage` class to create a message, and `ChannelManager` to send the message. ```typescript -// Set the message type. The SDK supports 8 message types. For details, see descriptions in ChatMessageType. -// You can send different types of messages by setting this parameter. +// Set the message type. The SDK supports 8 message types. const messageType = ChatMessageType.TXT; -// Set the user ID of the message recipient. +// Set `targetId` to the user ID of the peer user in one-to-one chat, group ID in group chat, and chat room ID in room chat. const targetId = "tom"; -// Set the chat type as a peer-to-peer chat, group chat, or chat room. For details, see descriptions in ChatMessageChatType. +// Set `chatType` as `PeerChat`, `GroupChat`, or `ChatRoom` for one-to-one chat, group chat, or room chat. const chatType = ChatMessageChatType.PeerChat; -// Construct the message. For different message types, you need to set the different parameters. +// Construct the message. Parameters vary with message types. let msg: ChatMessage; if (messageType === ChatMessageType.TXT) { // For a text message, set the message content. const content = "This is text message"; msg = ChatMessage.createTextMessage(targetId, content, chatType); } else if (messageType === ChatMessageType.IMAGE) { - // For am image message, set the file path, width, height, and display name of the image file. + // For an image message, set the file path, width, height, and display name of the image file. const filePath = "/data/.../image.jpg"; const width = 100; const height = 100; diff --git a/en-US/markdown/agora-chat/Develop/Messages/Send and Receive Messages/agora_chat_send_receive_message_unity.md b/en-US/markdown/agora-chat/Develop/Messages/Send and Receive Messages/agora_chat_send_receive_message_unity.md index d5b65e6b3b7..2fdebe66bcf 100644 --- a/en-US/markdown/agora-chat/Develop/Messages/Send and Receive Messages/agora_chat_send_receive_message_unity.md +++ b/en-US/markdown/agora-chat/Develop/Messages/Send and Receive Messages/agora_chat_send_receive_message_unity.md @@ -35,16 +35,20 @@ This section shows how to implement sending and receiving the various types of m Use the `Message` class to create a text message, and `IChannelManager` to send the message. ```C# -// Call CreateTextSendMessage to create a text message. Set `content` as the content of the text message, and `toChatUsernames` the user ID of the message recipient. -Message msg = Message.CreateTextSendMessage(toChatUsername, content); -// 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. +// Call CreateTextSendMessage to create a text message. +// Set `content` as the content of the text message. +// Set `conversationId` to the user ID of the peer user in one-to-one chat, group ID in group chat, and chat room ID in room chat. +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. -msg.MessageType = MessageType.Room; -msg.SetRoomMessagePriority(RoomMessagePriority.High); +// msg.MessageType = MessageType.Room; +// msg.SetRoomMessagePriority(RoomMessagePriority.High); + // Call SendMessage to send the message. -// When sending the message, you can instantiate a `Callback` object to listen for the result of the message sending. You can also update the message state in this callback, for example, by adding a pop-up box that reminds the message sending fails. +// When sending the message, you can instantiate a `Callback` object to listen for the result of the message sending. +// You can also update the message state in this callback, for example, by adding a pop-up box that reminds the message sending fails. SDKClient.Instance.ChatManager.SendMessage(ref msg, new CallBack( onSuccess: () => { Debug.Log($"{msg.MsgId} Message sending succeeds."); @@ -59,7 +63,7 @@ SDKClient.Instance.ChatManager.SendMessage(ref msg, new CallBack( You can use `IChatManagerDelegate` to listen for message events. You can add multiple `IChatManagerDelegates` to listen for multiple events. When you no longer listen for an event, ensure that you remove the delegate. -When a message arrives, the recipient receives an `OnMessgesReceived` callback. Each callback contains one or more messages. You can traverse the message list, and parse and render these messages in this callback and render these messages. +When a message arrives, the recipient receives an `OnMessagesReceived` callback. Each callback contains one or more messages. You can traverse the message list, and parse and render these messages in this callback and render these messages. ```C# // Inherit and instantiate IChatManagerDelegate. diff --git a/en-US/markdown/agora-chat/Develop/Messages/Send and Receive Messages/agora_chat_send_receive_message_web.md b/en-US/markdown/agora-chat/Develop/Messages/Send and Receive Messages/agora_chat_send_receive_message_web.md index 8caebad452b..8508d582fe9 100644 --- a/en-US/markdown/agora-chat/Develop/Messages/Send and Receive Messages/agora_chat_send_receive_message_web.md +++ b/en-US/markdown/agora-chat/Develop/Messages/Send and Receive Messages/agora_chat_send_receive_message_web.md @@ -39,14 +39,14 @@ function sendPrivateText() { let option = { // Set the message content. msg: "message content", - // Set the username of the receiver. - to: "username", - // Set the chat type + // Set the user ID of the recipient for one-to-one chat, group ID for group chat, or chat room ID for room chat. + to: "userId", + // Set `chatType` as `singleChat` for one-to-one chat, `groupChat` for group chat, or `chatRoom` for room chat. chatType: "singleChat", }; // Create a text message. let msg = AC.message.create(option); - // Call send to send the message + // Call `send` to send the message conn.send(msg).then((res)=>{ console.log("Send message success",res); }).catch((e)=>{ diff --git a/en-US/markdown/agora-chat/Develop/Messages/Send and Receive Messages/agora_chat_send_receive_message_windows.md b/en-US/markdown/agora-chat/Develop/Messages/Send and Receive Messages/agora_chat_send_receive_message_windows.md index 04726c17225..4d4fa2144df 100644 --- a/en-US/markdown/agora-chat/Develop/Messages/Send and Receive Messages/agora_chat_send_receive_message_windows.md +++ b/en-US/markdown/agora-chat/Develop/Messages/Send and Receive Messages/agora_chat_send_receive_message_windows.md @@ -35,16 +35,20 @@ This section shows how to implement sending and receiving the various types of m Use the `Message` class to create a text message, and `IChannelManager` to send the message. ```C# -// Call CreateTextSendMessage to create a text message. Set `content` as the content of the text message, and `toChatUsernames` the user ID of the message recipient. -Message msg = Message.CreateTextSendMessage(toChatUsername, content); -// 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. +// Call CreateTextSendMessage to create a text message. +// Set `content` as the content of the text message. +// Set `conversationId` to the user ID of the peer user in one-to-one chat, group ID in group chat, and chat room ID in room chat. +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. -msg.MessageType = MessageType.Room; -msg.SetRoomMessagePriority(RoomMessagePriority.High); + +// Set the priority of chat room messages. The default priority is `Normal`, indicating the normal priority. +// msg.MessageType = MessageType.Room; +// msg.SetRoomMessagePriority(RoomMessagePriority.High); + // Call SendMessage to send the message. -// When sending the message, you can instantiate a `Callback` object to listen for the result of the message sending. You can also update the message state in this callback, for example, by adding a pop-up box that reminds the message sending fails. +// When sending the message, you can instantiate a `Callback` object to listen for the result of the message sending. +// You can also update the message state in this callback, for example, by adding a pop-up box that reminds the message sending fails. SDKClient.Instance.ChatManager.SendMessage(ref msg, new CallBack( onSuccess: () => { Debug.Log($"{msg.MsgId} Message sending succeeds."); @@ -59,7 +63,7 @@ SDKClient.Instance.ChatManager.SendMessage(ref msg, new CallBack( You can use `IChatManagerDelegate` to listen for message events. You can add multiple `IChatManagerDelegates` to listen for multiple events. When you no longer listen for an event, ensure that you remove the delegate. -When a message arrives, the recipient receives an `OnMessgesReceived` callback. Each callback contains one or more messages. You can traverse the message list, and parse and render these messages in this callback and render these messages. +When a message arrives, the recipient receives an `OnMessagesReceived` callback. Each callback contains one or more messages. You can traverse the message list, and parse and render these messages in this callback and render these messages. ```C# // Inherit and instantiate IChatManagerDelegate.