Skip to content

Commit

Permalink
modify
Browse files Browse the repository at this point in the history
  • Loading branch information
haoxiuwen committed Sep 25, 2023
1 parent b951f1b commit 5efa36e
Show file tree
Hide file tree
Showing 7 changed files with 61 additions and 50 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand Down Expand Up @@ -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() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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.");
Expand All @@ -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.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)=>{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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.");
Expand All @@ -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.
Expand Down

0 comments on commit 5efa36e

Please sign in to comment.