Skip to content

Commit

Permalink
Merge branch 'signaling-2.2.2-milestone' of https://github.com/AgoraI…
Browse files Browse the repository at this point in the history
…O/Docs-Source into staging
  • Loading branch information
saudsami committed Dec 13, 2024
2 parents 48f4d18 + 616ddd1 commit 3ac8eda
Show file tree
Hide file tree
Showing 139 changed files with 9,470 additions and 1,030 deletions.
3 changes: 2 additions & 1 deletion shared/common/prerequities-get-started.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,9 @@
- An Apple developer account
</PlatformWrapper>
<PlatformWrapper platform="windows">
- A device running Windows 7 or higher.
- A device running Windows 10 or higher.
- Microsoft Visual Studio 2017 or higher with [Desktop development with C++](https://devblogs.microsoft.com/cppblog/windows-desktop-development-with-c-in-visual-studio/) support.
- C++ 11 or higher.
</PlatformWrapper>
<PlatformWrapper platform="web">
- A [supported browser](../reference/supported-platforms#browsers).
Expand Down
10 changes: 10 additions & 0 deletions shared/common/supported-platforms/windows.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,14 @@

</ProductWrapper>

<ProductWrapper product="signaling">
- *Platforms*:
| Target Platform | Operating system version | IDE version |
|:-----------------|:-------|:-----|
| Windows | Windows 10 or later. <Vpd k="SDK" /> supports the following architectures: <ul><li>x86</li><li>x86-64</li></ul> | Microsoft Visual Studio 2017 or later |

- C++ 11 and above

</ProductWrapper>

</PlatformWrapper>
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<PlatformWrapper platform="linux-cpp">
<PlatformWrapper platform="linux-cpp, windows">

### Add an event listener

Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,57 @@
<PlatformWrapper platform="ios, macos">
import Tabs from '@theme/Tabs';
import TabItem from '@theme/TabItem';
import CodeBlock from '@theme/CodeBlock';

### Add an event listener

<Vg k="SIG"/> uses `RtmListener` to process messages and event notifications. Each message and event notification has a corresponding event handler, where you implement your own processing logic. Refer to the following code to create and use an instance of `RtmListener`:

```swift
// Define the Event Listener
<Tabs groupId="language">
<TabItem value="swift" label="Swift" default>
<CodeBlock language="swift" showLineNumbers>
{`class RtmListener: NSObject, AgoraRtmClientDelegate {
func rtmKit(_ rtmKit: AgoraRtmClientKit, didReceiveLinkStateEvent event: AgoraRtmLinkStateEvent) {
// code
}
func rtmKit(_ rtmKit: AgoraRtmClientKit, didReceiveMessageEvent event: AgoraRtmMessageEvent) {
// code
}
func rtmKit(_ rtmKit: AgoraRtmClientKit, didReceiveLockEvent event: AgoraRtmLockEvent) {
// code
}
func rtmKit(_ rtmKit: AgoraRtmClientKit, didReceiveTopicEvent event: AgoraRtmTopicEvent) {
// code
}
func rtmKit(_ rtmKit: AgoraRtmClientKit, didReceiveStorageEvent event: AgoraRtmStorageEvent) {
// code
}
func rtmKit(_ rtmKit: AgoraRtmClientKit, tokenPrivilegeWillExpire channel: String?) {
// code
}
}
do {
let config = AgoraRtmClientConfig(appId: "yourAppId", userId: "uniqueUserId")
let listener = RtmListener()
// Initializing the RTM client
let rtmClient = try AgoraRtmClientKit(config, delegate: listener)
if rtmClient != nil {
print("RTM Client initialized successfully!")
}
} catch let error {
print("Failed to initialize RTM client. Error: \\(error)")
}`}
</CodeBlock>
</TabItem>
<TabItem value="objc" label="Objective-C">
<CodeBlock language="objc" showLineNumbers>
{`// Define the Event Listener
@interface RtmListener : NSObject <AgoraRtmClientDelegate>
@end
Expand Down Expand Up @@ -100,12 +146,15 @@ AgoraRtmClientConfig* rtm_cfg = [[AgoraRtmClientConfig alloc] initWithAppId:@"yo
// Add the event listener
RtmListener* handler = [[RtmListener alloc] init];
NSError* initError = nil;
AgoraRtmClientKit* rtm = [[AgoraRtmClientKit alloc] initWithConfig:rtm_cfg delegate:handler error:&initError];
```
AgoraRtmClientKit* rtm = [[AgoraRtmClientKit alloc] initWithConfig:rtm_cfg delegate:handler error:&initError];`}
</CodeBlock>
After a user successfully joins a topic, the SDK triggers an `didReceiveTopicEvent` of type `AgoraRtmTopicEventTypeRemoteJoinTopic`. All users in the channel, who have enabled listening to topic events, receive this event notification.
</TabItem>
</Tabs>

### Remove event listeners

To avoid performance degradation caused by memory leaks, errors, and exceptions, best practice is to unregister an event handler when you no longer need to use it. For example, if you don't want to use the ` -(void) rtmKit:(AgoraRtmClientKit *)rtmKit didReceiveLockEvent:(AgoraRtmLockEvent *)` event, delete the definition of the function.
To avoid performance degradation caused by memory leaks, errors, and exceptions, best practice is to unregister an event handler when you no longer need to use it. For example, if you don't want to use the `didReceiveLockEvent` event, delete the definition of the function.

### Signaling events

Expand All @@ -121,7 +170,6 @@ To avoid performance degradation caused by memory leaks, errors, and exceptions,
| `didReceiveLockEvent` | Receive all lock event notifications in all the message channels you have subscribed to and stream channels you have joined. The event payload data contains information such as channel name, channel type, event type, and lock details. |
| `didReceiveLinkStateEvent` | Receive event notifications for client network connection status changes, including the connection status before and after the change, service type, operation type that caused the change, reason for the change, channel list, and other information. |
| `tokenPrivilegeWillExpire`| Receive event notifications that the client token is about to expire. |
| `connectionChangedToState` | (Deprecated) Receive event notifications of client network connection status changes, including channel name, connection status, and reason for change. |

For details on the parameters passed in by each event, refer to [Event listeners](../reference/api?#event-listeners) in the API reference.

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<PlatformWrapper platform="linux-cpp">
<PlatformWrapper platform="linux-cpp, windows">

### Login with a token

Expand Down
Original file line number Diff line number Diff line change
@@ -1,21 +1,41 @@
<PlatformWrapper platform="ios, macos">
import Tabs from '@theme/Tabs';
import TabItem from '@theme/TabItem';
import CodeBlock from '@theme/CodeBlock';
import * as enumv from '@docs/shared/signaling/reference/api-ref/shared/_enumv.mdx'

### Login with a token

To log in to <Vg k="SIG" /> using an RTM token, fetch a token from your token server and pass it to the SDK by calling `loginByToken`:

```objc
// Fetch a token from your token server
To log in using an RTM token, fetch the token from your token server and provide it to the SDK during the login process:

<Tabs groupId="language">
<TabItem value="swift" label="Swift" default>
<CodeBlock language="swift" showLineNumbers>
{`// Fetch a token from your token server
// Log in to Signaling
rtm.login(token) {res, error in
if error != nil {
print("\\(error?.operation) failed! error reason is \\(error?.reason)")
} else {
print("success")
}
}`}
</CodeBlock>
</TabItem>
<TabItem value="objc" label="Objective-C">
<CodeBlock language="objc" showLineNumbers>
{`// Fetch a token from your token server
// Log in to Signaling
[rtm loginByToken:@"your_token" completion:^(AgoraRtmCommonResponse * _Nullable response, AgoraRtmErrorInfo * _Nullable errorInfo) {
if (errorInfo == nil) {
NSLog(@"login success!!");
} else {
NSLog(@"login failed, errorCode %d, reason %@", errorInfo.errorCode, errorInfo.reason);
}
}];
```
}];`}
</CodeBlock>
</TabItem>
</Tabs>

<Admonition title="Note">
- The user ID and app ID you use to initialize the <Vg k="SIG" /> client instance must be the same as the user ID and app ID you use on the token server to generate a token.
Expand All @@ -24,19 +44,28 @@ To log in to <Vg k="SIG" /> using an RTM token, fetch a token from your token se

### Join a stream channel using a token

To join a stream channel using a token, fetch an **RTC** token from your token server and pass it to the SDK when you call `joinWithOption`. For details, refer to the [API reference](../reference/api#channeljoinpropsag_platform).
To join a stream channel using a token, fetch the token from your token server and provide it to the SDK during the join process. For details, refer to the [API reference](../reference/api#channeljoinpropsag_platform).

### Token expiration and renewal

You configure the validity period of an RTM token in your token generator according to your business needs. The maximum validity period of a token is 24 hours. When an RTM token is about to expire, the `tokenPrivilegeWillExpire` callback is triggered 30 seconds before the expiration time. When you receive this callback, retrieve a fresh RTM token from your token server, and call `renewToken` to pass the new token to the SDK.
You configure the validity period of an RTM token in your token generator according to your business needs. The maximum validity period of a token is 24 hours. When an RTM token is about to expire, the `tokenPrivilegeWillExpire` callback is triggered 30 seconds before the expiration time. When you receive this callback, retrieve a fresh RTM token from your token server, and call [`renewToken`](../reference/api?platform=ios#tokenrenewrtmtokenpropsag_platform) to pass the new token to the SDK.

If the token expires, the SDK triggers an `didReceiveLinkStateEvent` callback and reports the following information:

- `currentState`: `AgoraRtmLinkStateFailed`
- `operation`: `AgoraRtmLinkOperationServerReject`
- `reason`: `Ticket expired`
<Tabs groupId="language">
<TabItem value="swift" label="Swift" default>
- `currentState`: <code>{enumv.linkstatefailed["swift"]}</code>
- `operation`: <code>{enumv.linkoperationreject["swift"]}</code>
- `reason`: <code>{enumv.linkstatereasontokenexpired["swift"]}</code>
</TabItem>
<TabItem value="objc" label="Objective-C">
- `currentState`: <code>{enumv.linkstatefailed["ios"]}</code>
- `operation`: <code>{enumv.linkoperationreject["ios"]}</code>
- `reason`: <code>{enumv.linkstatereasontokenexpired["ios"]}</code>
</TabItem>
</Tabs>

In this scenario, log out of <Vpd k="NAME" /> using the `logout` method, retrieve a fresh token, and `loginByToken` again.
In this scenario, use the `logout` method to log out of <Vpd k="NAME" />, retrieve a fresh token, and then log in again.

<Admonition type="info">
An alternative approach to handling token expiration through the `tokenPrivilegeWillExpire` and `didReceiveLinkStateEvent` callbacks is to handle expiration proactively. Best practice is to update the token periodically to ensure seamless authentication and uninterrupted operation.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
<PlatformWrapper platform="linux-cpp">
<PlatformWrapper platform="linux-cpp, windows">

</PlatformWrapper>
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<PlatformWrapper platform='linux-cpp'>
<PlatformWrapper platform='linux-cpp, windows'>
import ChannelTypes from './channel-types-22x.mdx'

<ChannelTypes channelType="RTM_CHANNEL_TYPE_USER" messageEvent="onMessageEvent" />
Expand Down
2 changes: 1 addition & 1 deletion shared/signaling/channel-basics/channel-types/obj-c.mdx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<PlatformWrapper platform={['ios','macos']}>
import ChannelTypes from './channel-types-22x.mdx'

<ChannelTypes channelType="AgoraRtmChannelTypeUser" messageEvent="didReceiveMessageEvent" />
<ChannelTypes channelType="user" messageEvent="didReceiveMessageEvent" />

</PlatformWrapper>
2 changes: 1 addition & 1 deletion shared/signaling/channel-basics/create-channel/android.mdx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<PlatformWrapper platform='android'>
import CreateChannel from './common.mdx'

<CreateChannel createStreamChannel="createStreamChannel" streamChannel="StreamChannel" join="join" />
<CreateChannel createStreamChannel="createStreamChannel" streamChannel="StreamChannel" />
</PlatformWrapper>
2 changes: 1 addition & 1 deletion shared/signaling/channel-basics/create-channel/common.mdx
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
For message channels, you do not need to define or create a channel before using it. When you send a message or subscribe to a message channel for the first time, <Vg k="SIG" /> automatically creates the channel for you.

When using stream channels, although a channel is essentially ready-to-use, you must explicitly call the <code>{props.createStreamChannel}</code> method to create an instance of a <code>{props.streamChannel}</code> object, before you call the <code>{props.join}</code> method to join the channel.
When using stream channels, although a channel is essentially ready-to-use, you must explicitly call the <code>{props.createStreamChannel}</code> method to create an instance of a <code>{props.streamChannel}</code> object, before joining the channel.
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<PlatformWrapper platform='linux-cpp'>
import CreateChannel from './common.mdx'

<CreateChannel createStreamChannel="createStreamChannel" streamChannel="IStreamChannel" join="join" />
<CreateChannel createStreamChannel="createStreamChannel" streamChannel="IStreamChannel" />
</PlatformWrapper>
2 changes: 1 addition & 1 deletion shared/signaling/channel-basics/create-channel/obj-c.mdx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<PlatformWrapper platform={['ios','macos']}>
import CreateChannel from './common.mdx'

<CreateChannel createStreamChannel="createStreamChannel" streamChannel="AgoraRtmStreamChannel" join="joinWithOption" />
<CreateChannel createStreamChannel="createStreamChannel" streamChannel="AgoraRtmStreamChannel" />
</PlatformWrapper>
2 changes: 1 addition & 1 deletion shared/signaling/channel-basics/create-channel/unity.mdx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<PlatformWrapper platform='unity'>
import CreateChannel from './common.mdx'

<CreateChannel createStreamChannel="CreateStreamChannel" streamChannel="IStreamChannel" join="JoinAsync" />
<CreateChannel createStreamChannel="CreateStreamChannel" streamChannel="IStreamChannel" />
</PlatformWrapper>
2 changes: 1 addition & 1 deletion shared/signaling/channel-basics/create-channel/web.mdx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<PlatformWrapper platform='web'>
import CreateChannel from './common.mdx'

<CreateChannel createStreamChannel="createStreamChannel" streamChannel="RTMStreamChannel" join="join" />
<CreateChannel createStreamChannel="createStreamChannel" streamChannel="RTMStreamChannel" />
</PlatformWrapper>
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<PlatformWrapper platform="linux-cpp">
<PlatformWrapper platform="linux-cpp, windows">

### Geographical area configuration

Expand Down
Loading

0 comments on commit 3ac8eda

Please sign in to comment.