Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Signaling updates + User channel doc #1569

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ In some environments with restricted network services, you may need to set up a
```java
RtmProxyConfig proxyConfig = new RtmProxyConfig()


// Set proxy type as HTTP.
proxyConfig.proxyType = RtmProxyType.HTTP;
// Set your proxy server address.
Expand Down Expand Up @@ -66,6 +67,23 @@ RtmConfig rtmConfig = new RtmConfig.Builder("appid", "userId")
To deploy a private environment, you need to set up the backend service. For assistance, please contact [technical support](mailto:[email protected]).
</Admonition>


### Connection protocol

To ensure connection stability and continuous service availability, the RTM client establishes two transmission links for each service (message channel and stream channel) when connecting to the edge server. By default, these links use the TCP and UDP protocols, respectively. This design ensures that network issues on one link do not affect the overall transmission. Compared to other WebSocket-based message transmission solutions, RTM's redundant link design maximizes transmission stability and message delivery rate.

In some cases, users may find that their network does not support UDP port transmission, either temporarily or permanently. To ensure the dual-link design operates effectively, the SDK allows users to configure both links to use the TCP protocol. This can be done by setting the `protocolType` field in the `RtmConfig`. Below is a code example that configures both links to use the TCP protocol:

```java
RtmConfig rtmConfig = new RtmConfig.Builder("appid", "userId")
.protocolType(RtmProtocolType.TCP_ONLY)
.build();
```

<Admonition type="alert" info="info">
The SDK does not support configuring both links to use the UDP protocol simultaneously.
</Admonition>

### Log configuration

In the development and testing phase of your <Vpl k="CLIENT" />, you may need to output more detailed information to locate and fix problems. Enable log output of the SDK and set the log information level by configuring `RtmLogLevel` when initializing the <Vg k="SIG" /> client instance.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,22 @@ private_config.serviceType = AgoraRtmServiceTypeStream | AgoraRtmServiceTypeMess
To deploy a private environment, you need to set up the backend service. For assistance, please contact [technical support](mailto:[email protected]).
</Admonition>

### Connection protocol

To ensure connection stability and continuous service availability, the RTM client establishes two transmission links for each channel (message channel and stream channel) when connecting to the edge server. By default, these links use the TCP and UDP protocols respectively. This design ensures that network issues in one link do not affect transmission performance. Compared to other WebSocket-based message transmission solutions, RTM's redundant link design maximizes transmission stability and message arrival rates.

In some cases, users may find that their network does not support UDP port transmission, either temporarily or permanently. To ensure the dual-link design functions effectively, the SDK allows users to configure both links to use the TCP protocol by setting the `protocolType` field in the `AgoraRtmClientConfig`. Here is an example of configuring both links to use the TCP protocol:

```objc
AgoraRtmClientConfig* rtm_config = [[AgoraRtmClientConfig alloc] initWithAppId:@"your_appid" userId:@"your_userid"];
rtm_config.protocolType = AgoraRtmProtocolTypeTcpOnly;
```
<Admonition type="alert" info="info">
The SDK does not support configuring both links to use the UDP protocol simultaneously.
</Admonition>



### Log configuration

In the development and testing phase of your <Vpl k="CLIENT" />, you may need to output more detailed information to locate and fix problems. Enable log output of the SDK and set the log information level by configuring `AgoraRtmLogLevel` when initializing the <Vg k="SIG" /> client instance.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ Refer to the following sample code for sending messages:
```

<Admonition>
<Vg k="SIG" /> currently supports only string and binary message formats. To send other types of data such as a JSON, object, or data from third-party data construction tools such as protobuf, serialize the data before sending the message. For information on how to effectively construct the payload data structure and recommended serialization methods, refer to [Message payload structuring](../best-practices/message-payload-structuring).
<Vg k="SIG" /> currently supports only string and binary message formats. To send other types of data such as a JSON objects, or data from third-party data construction tools such as protobuf, serialize the data before sending the message. For information on how to effectively construct the payload data structure and recommended serialization methods, refer to [Message payload structuring](../best-practices/message-payload-structuring).
</Admonition>

### Customize channel subscription
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ Refer to the following sample code for sending messages:
}
```
<Admonition>
<Vg k="SIG" /> currently supports only string and binary message formats. To send other types of data such as a JSON, object, or data from third-party data construction tools such as protobuf, serialize the data before sending the message. For information on how to effectively construct the payload data structure and recommended serialization methods, refer to [Message payload structuring](../best-practices/message-payload-structuring).
<Vg k="SIG" /> currently supports only string and binary message formats. To send other types of data such as a JSON objects, or data from third-party data construction tools such as protobuf, serialize the data before sending the message. For information on how to effectively construct the payload data structure and recommended serialization methods, refer to [Message payload structuring](../best-practices/message-payload-structuring).
</Admonition>

When you call `publish`, the SDK triggers the `onPublishResult` callback.
Expand Down
2 changes: 1 addition & 1 deletion shared/signaling/message-channels/implementation/obj-c.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ Refer to the following sample code for sending messages:
```

<Admonition>
<Vg k="SIG" /> currently supports only string and binary message formats. To send other types of data such as a JSON, object, or data from third-party data construction tools such as protobuf, serialize the data before sending the message. For information on how to effectively construct the payload data structure and recommended serialization methods, refer to [Message payload structuring](../best-practices/message-payload-structuring).
<Vg k="SIG" /> currently supports only string and binary message formats. To send other types of data such as a JSON objects, or data from third-party data construction tools such as protobuf, serialize the data before sending the message. For information on how to effectively construct the payload data structure and recommended serialization methods, refer to [Message payload structuring](../best-practices/message-payload-structuring).
</Admonition>

### Customize channel subscription
Expand Down
2 changes: 1 addition & 1 deletion shared/signaling/message-channels/implementation/unity.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ Refer to the following sample code for sending messages:
```

<Admonition>
<Vg k="SIG" /> currently supports only string and binary message formats. To send other types of data such as a JSON, object, or data from third-party data construction tools such as protobuf, serialize the data before sending the message. For information on how to effectively construct the payload data structure and recommended serialization methods, refer to [Message payload structuring](../best-practices/message-payload-structuring).
<Vg k="SIG" /> currently supports only string and binary message formats. To send other types of data such as a JSON objects, or data from third-party data construction tools such as protobuf, serialize the data before sending the message. For information on how to effectively construct the payload data structure and recommended serialization methods, refer to [Message payload structuring](../best-practices/message-payload-structuring).
</Admonition>

### Customize channel subscription
Expand Down
2 changes: 1 addition & 1 deletion shared/signaling/message-channels/implementation/web.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ Refer to the following sample code for sending messages:
```

<Admonition>
<Vg k="SIG" /> currently supports only string and binary message formats. To send other types of data such as a JSON, object, or data from third-party data construction tools such as protobuf, serialize the data before sending the message. For information on how to effectively construct the payload data structure and recommended serialization methods, refer to [Message payload structuring](../best-practices/message-payload-structuring).
<Vg k="SIG" /> currently supports only string and binary message formats. To send other types of data such as a JSON objects, or data from third-party data construction tools such as protobuf, serialize the data before sending the message. For information on how to effectively construct the payload data structure and recommended serialization methods, refer to [Message payload structuring](../best-practices/message-payload-structuring).
</Admonition>

### Customize channel subscription
Expand Down
43 changes: 43 additions & 0 deletions shared/signaling/user-channel/index.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
import ProjectImplement from '@docs/shared/signaling/user-channel/project-implementation/index.mdx';
import Reference from '@docs/shared/signaling/user-channel/reference/index.mdx';
import NotAvailable from '@docs/shared/common/not-available.mdx';

<PlatformWrapper platform="[android,ios,macos]">
<Vpd k="NAME" /> enables you to send direct, point-to-point messages to individual users through user channels. This feature is useful in one-on-one communication scenarios such as private chats and customer support interactions.

## Understand the tech

To implement point-to-point communication between individual users in your <Vpl k="CLIENT"/>:

1. **Set up the <Vpd k="SDK" />**: [Integrate the <Vpd k="SDK" />](../get-started/sdk-quickstart#integrate-the-sdk) in your app and [initialize an instance](../get-started/sdk-quickstart#initialize-the-signaling-engine) of the <Vpd k="NAME" /> client.
2. **Authenticate the user**: [Log in to <Vg k="SIG" />](../get-started/sdk-quickstart#log-in-to-signaling) using a unique user ID.
3. **Send direct messages**: Call the `publish` method with the User channel type and specify the recipient's user ID as the channel name to send direct messages.
4. **Handle incoming messages**: [Listen for message events](../get-started/sdk-quickstart#add-an-event-listener) to receive messages sent directly to the local user.

## Prerequisites

Ensure that you have:

* Integrated the <Vpd k="SDK" /> in your project, and implemented the framework functionality from the [SDK quickstart](../get-started/sdk-quickstart).

## Implement user messages

This section shows you how to use the <Vpd k="SDK" /> to send messages directly to a specified user.

<ProjectImplement/>

<Admonition>
<Vg k="SIG" /> currently supports only string and binary message formats. To send other types of data such as a JSON objects, or data from third-party data construction tools such as protobuf, serialize the data before sending the message. For information on how to effectively construct the payload data structure and recommended serialization methods, refer to [Message payload structuring](../best-practices/message-payload-structuring).
</Admonition>

## Reference

This section contains information that completes the information in this page, or points you to documentation that explains other aspects to this product.

<Reference/>
</PlatformWrapper>

<PlatformWrapper notAllowed="[android, ios, macos]">
<NotAvailable />
</PlatformWrapper>

48 changes: 48 additions & 0 deletions shared/signaling/user-channel/project-implementation/android.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
<PlatformWrapper platform="android">

To send message to a user channel, call the `publish` method with the `channelType` parameter set to `RtmChannelType.USER` and the `channelName` parameter set to the target user's `userId`. This method enables you to send a message to one user at a time. To send messages to multiple users, call this method for each user. While <Vg k="SIG" /> does not limit the number of users you can send messages to or receive messages from, it does [limit](../reference/limitations#message-channel) the frequency at which you can send messages to users.

Refer to the following sample code for sending messages:

- String message

```java
// Send string message
PublishOptions options = new PublishOptions();
options.setChannelType(RtmChannelType.USER);
options.setCustomType("PlainText");
rtmClient.publish("Tony", "Hello world", options, new ResultCallback<Void>() {
@Override
public void onSuccess(Void responseInfo) {
log(CALLBACK, "Send message success");
}

@Override
public void onFailure(ErrorInfo errorInfo) {
log(ERROR, errorInfo.toString());
}
});
```

- Binary message

```java
// Send binary message
byte[] message = new byte[] {1, 2, 3, 4};
PublishOptions options = new PublishOptions();
options.setChannelType(RtmChannelType.USER);
options.setCustomType("ByteArray");
rtmClient.publish("Tony", message, options, new ResultCallback<Void>() {
@Override
public void onSuccess(Void responseInfo) {
log(CALLBACK, "Send message success");
}

@Override
public void onFailure(ErrorInfo errorInfo) {
log(ERROR, errorInfo.toString());
}
});
```

</PlatformWrapper>
11 changes: 11 additions & 0 deletions shared/signaling/user-channel/project-implementation/index.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import Android from './android.mdx'
import ObjC from './obj-c.mdx'
import LinuxCpp from './linux-cpp.mdx'
import Web from './web.mdx'
import Unity from './unity.mdx'

<Android />
<ObjC />
<LinuxCpp />
<Web />
<Unity />
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
<PlatformWrapper platform="linux-cpp">


</PlatformWrapper>
45 changes: 45 additions & 0 deletions shared/signaling/user-channel/project-implementation/obj-c.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
<PlatformWrapper platform="ios, macos">

In a user channel, you send a point-to-point message to a specified user by calling the `publish` method. Set the `channelType` parameter to `AgoraRtmChannelTypeUser` and the `channelName` parameter to the user ID of the specified user. This method enables you to send messages to one user at a time. To send messages to multiple users, call this method multiple times. While <Vg k="SIG" /> does not limit the number of users you can send messages to or receive messages from, it does [limit](../reference/limitations#message-channel) the frequency at which you can send messages to users.

Refer to the following sample code for sending messages:

- String message

```objc
// Send string message
NSString* message = @"Hello Agora!";
NSString* user = @"Tony";

AgoraRtmPublishOptions* publish_option = [[AgoraRtmPublishOptions alloc] init];
publish_option.channelType = AgoraRtmChannelTypeUser;

[rtm publish:user message:message option:publish_option completion:^(AgoraRtmCommonResponse * _Nullable response, AgoraRtmErrorInfo * _Nullable errorInfo) {
if (errorInfo == nil) {
NSLog(@"publish success!!");
} else {
NSLog(@"publish failed, errorCode %d, reason %@", errorInfo.errorCode, errorInfo.reason);
}
}];
```

- Binary message

```objc
// Send string message
NSString* message = @"Hello Agora!";
NSString* user = @"Tony";

AgoraRtmPublishOptions* publish_option = [[AgoraRtmPublishOptions alloc] init];
publish_option.channelType = AgoraRtmChannelTypeUser;

[rtm publish:user message:message option:publish_option completion:^(AgoraRtmCommonResponse * _Nullable response, AgoraRtmErrorInfo * _Nullable errorInfo) {
if (errorInfo == nil) {
NSLog(@"publish success!!");
} else {
NSLog(@"publish failed, errorCode %d, reason %@", errorInfo.errorCode, errorInfo.reason);
}
}];
```

</PlatformWrapper>
Loading
Loading