diff --git a/.github/workflows/terra.yml b/.github/workflows/terra.yml index 04fc93c..b1e7416 100644 --- a/.github/workflows/terra.yml +++ b/.github/workflows/terra.yml @@ -2,11 +2,6 @@ name: Generate codes on: workflow_dispatch: - inputs: - terra-ref: - description: The terra repo ref - required: true - default: 'main' jobs: generate-codes: @@ -14,37 +9,22 @@ jobs: steps: - name: Checkout uses: actions/checkout@v4 + with: + fetch-depth: 0 + token: ${{ secrets.GITHUB_TOKEN }} - name: Setup uses: ./.github/actions/setup - - name: Generate codes - id: terra - uses: AgoraIO-Extensions/actions/.github/actions/terra@main - env: - LLVM_DOWNLOAD_URL: | - https://github.com/llvm/llvm-project/releases/download/llvmorg-15.0.6/clang+llvm-15.0.6-x86_64-linux-gnu-ubuntu-18.04.tar.xz + - name: Generate code and comment by terra + uses: AgoraIO-Extensions/actions/.github/actions/generate@main with: github-token: ${{ secrets.GH_TOKEN }} - terra-ref: ${{ inputs.terra-ref }} - config: ci/config/terra_config.yaml - output-dir: src - export-file-path: src/index.ts - - - name: Format codes - run: | - rm -rf terra - yarn lint --fix - - - name: Generate ts interface - run: | - yarn - - - name: Generate comments - uses: ./.github/actions/doc - with: - github-token: ${{ secrets.GH_TOKEN }} - target-path: ${{ github.workspace }} + generate-code: true + generate-comment: true + generate-code-command: | + sh generate-prepare.sh + sh generate-code.sh - name: Create pull request uses: AgoraIO-Extensions/actions/.github/actions/pr@main @@ -55,8 +35,4 @@ jobs: target-branch-name-surffix: terra-update pull-request-title: | [AUTO] Generate codes by terra - pull-request-body: | - Terra configuration: - - ${{ steps.terra.outputs.configuration }} add-paths: src diff --git a/agora-react-native-rtm.podspec b/agora-react-native-rtm.podspec index 24a21b6..f1550e8 100755 --- a/agora-react-native-rtm.podspec +++ b/agora-react-native-rtm.podspec @@ -40,8 +40,8 @@ Pod::Spec.new do |s| end end - s.dependency 'AgoraRtm_iOS', '2.1.7' - s.dependency 'AgoraIrisRTM_iOS', '2.1.7-build.1' + s.dependency 'AgoraRtm_iOS', '2.1.12' + s.dependency 'AgoraIrisRTM_iOS', '2.1.12-dev.1' s.libraries = 'stdc++' s.framework = 'ReplayKit' end diff --git a/android/build.gradle b/android/build.gradle index e60f0cd..5bcf2b3 100755 --- a/android/build.gradle +++ b/android/build.gradle @@ -162,8 +162,8 @@ dependencies { //noinspection GradleDynamicVersion implementation "com.facebook.react:react-native:+" implementation fileTree(include: ['*.jar', '*.aar'], dir: 'libs') - implementation "io.agora:agora-rtm:2.1.7" - implementation "io.agora.rtm:iris-rtm:2.1.7-build.1" + implementation "io.agora:agora-rtm:2.1.12" + implementation "io.agora.rtm:iris-rtm:2.1.12-dev.1" } diff --git a/example/ios/Podfile.lock b/example/ios/Podfile.lock index 781b465..1d8d247 100644 --- a/example/ios/Podfile.lock +++ b/example/ios/Podfile.lock @@ -1,11 +1,11 @@ PODS: - - agora-react-native-rtm (2.1.7): - - AgoraIrisRTM_iOS (= 2.1.7-build.1) - - AgoraRtm_iOS (= 2.1.7) + - agora-react-native-rtm (2.1.12): + - AgoraIrisRTM_iOS (= 2.1.12-dev.1) + - AgoraRtm_iOS (= 2.1.12) - RCT-Folly (= 2021.07.22.00) - React-Core - AgoraIrisRTC_iOS (4.3.1-build.1) - - AgoraIrisRTM_iOS (2.1.7-build.1) + - AgoraIrisRTM_iOS (2.1.12-dev.1) - AgoraRtcEngine_iOS (4.3.1): - AgoraRtcEngine_iOS/AIAEC (= 4.3.1) - AgoraRtcEngine_iOS/AINS (= 4.3.1) @@ -41,7 +41,7 @@ PODS: - AgoraRtcEngine_iOS/VideoCodecEnc (4.3.1) - AgoraRtcEngine_iOS/VirtualBackground (4.3.1) - AgoraRtcEngine_iOS/VQA (4.3.1) - - AgoraRtm_iOS (2.1.7) + - AgoraRtm_iOS (2.1.12) - boost (1.76.0) - CocoaAsyncSocket (7.6.5) - DoubleConversion (1.1.6) @@ -754,11 +754,11 @@ EXTERNAL SOURCES: :path: "../node_modules/react-native/ReactCommon/yoga" SPEC CHECKSUMS: - agora-react-native-rtm: db09801b83ccbde861b8261e00bc46a03f8f4136 + agora-react-native-rtm: feac636a75ebb40a3c29072a823d8442babdc87b AgoraIrisRTC_iOS: 7710d853202eca4900c2916aefc44abd5a139d4e - AgoraIrisRTM_iOS: 588c042feef52bb2545e3618da1e442f19e2cf5b + AgoraIrisRTM_iOS: 8333f60aeee673e88fcf02a0f627484f21731f67 AgoraRtcEngine_iOS: f64be00fdda786bb7edd84ab461c31b7b4c93534 - AgoraRtm_iOS: cd26cf8a377a79934864d37e184866dbd1430eaf + AgoraRtm_iOS: 54dbd6c1f33f1d7432becf1d271713bcc35653cb boost: 57d2868c099736d80fcd648bf211b4431e51a558 CocoaAsyncSocket: 065fd1e645c7abab64f7a6a2007a48038fdc6a99 DoubleConversion: 5189b271737e1565bdce30deb4a08d647e3f5f54 diff --git a/example/src/advanced/ChannelMetadata/index.tsx b/example/src/advanced/ChannelMetadata/index.tsx index 17e3a7c..836f0ec 100644 --- a/example/src/advanced/ChannelMetadata/index.tsx +++ b/example/src/advanced/ChannelMetadata/index.tsx @@ -451,6 +451,7 @@ export default function ChannelMetadata() { onChangeText={(text) => { if (!text) return; setMajorRevision(parseInt(text, 10)); + metadata.current.majorRevision = parseInt(text, 10); }} label="majorRevision" value={majorRevision.toString()} diff --git a/example/src/advanced/UseRTC/index.tsx b/example/src/advanced/UseRTC/index.tsx index 299e3a7..02b0c65 100644 --- a/example/src/advanced/UseRTC/index.tsx +++ b/example/src/advanced/UseRTC/index.tsx @@ -10,7 +10,11 @@ import { import React, { useCallback, useEffect, useState } from 'react'; import { KeyboardAvoidingView, Platform, ScrollView } from 'react-native'; -import { ChannelProfileType, createAgoraRtcEngine } from 'react-native-agora'; +import { + ChannelProfileType, + SDKBuildInfo, + createAgoraRtcEngine, +} from 'react-native-agora'; import { AgoraButton, @@ -24,7 +28,10 @@ import * as log from '../../utils/log'; export default function UseRTC() { const [uid, setUid] = useState(Config.uid); - const [rtcVersion, setRtcVersion] = useState(Config.uid); + const [rtcVersion, setRtcVersion] = useState({ + version: '', + build: 0, + }); const [loginSuccess, setLoginSuccess] = useState(false); const [initResult, setInitResult] = useState(0); const onLoginResult = useCallback((errorCode: RTM_ERROR_CODE) => { @@ -126,6 +133,7 @@ export default function UseRTC() { useEffect(() => { let engine = createAgoraRtcEngine(); + console.log(engine.getVersion()); engine.initialize({ appId: Config.appId, channelProfile: ChannelProfileType.ChannelProfileLiveBroadcasting, diff --git a/example/src/advanced/UserMetadata/index.tsx b/example/src/advanced/UserMetadata/index.tsx index 6eb24c6..8354faf 100644 --- a/example/src/advanced/UserMetadata/index.tsx +++ b/example/src/advanced/UserMetadata/index.tsx @@ -406,6 +406,7 @@ export default function UserMetadata() { onChangeText={(text) => { if (!text) return; setMajorRevision(parseInt(text, 10)); + metadata.current.majorRevision = parseInt(text, 10); }} label="majorRevision" value={majorRevision.toString()} diff --git a/example/src/advanced/publishMessage/index.tsx b/example/src/advanced/publishMessage/index.tsx index c934a6b..d1e45b1 100644 --- a/example/src/advanced/publishMessage/index.tsx +++ b/example/src/advanced/publishMessage/index.tsx @@ -3,26 +3,38 @@ import { Buffer } from 'buffer'; import { MessageEvent, PublishOptions, + RTM_CHANNEL_TYPE, RTM_CONNECTION_CHANGE_REASON, RTM_CONNECTION_STATE, RTM_ERROR_CODE, RTM_MESSAGE_TYPE, + RTM_PROXY_TYPE, } from 'agora-react-native-rtm'; import React, { useCallback, useEffect, useState } from 'react'; import { GiftedChat } from 'react-native-gifted-chat'; import BaseComponent from '../../components/BaseComponent'; -import { AgoraButton, AgoraStyle, AgoraView } from '../../components/ui'; +import { + AgoraButton, + AgoraDivider, + AgoraDropdown, + AgoraStyle, + AgoraView, +} from '../../components/ui'; import Config from '../../config/agora.config'; import { useRtmClient } from '../../hooks/useRtmClient'; import { AgoraMessage } from '../../types'; import * as log from '../../utils/log'; +import { enumToItems } from '../../utils'; export default function PublishMessage() { const [loginSuccess, setLoginSuccess] = useState(false); const [subscribeSuccess, setSubscribeSuccess] = useState(false); const [publishMessageByBuffer, setPublishMessageByBuffer] = useState(false); const [cName, setCName] = useState(Config.channelName); + const [channelType, setChannelType] = useState( + RTM_CHANNEL_TYPE.RTM_CHANNEL_TYPE_MESSAGE + ); const [uid, setUid] = useState(Config.uid); const [messages, setMessages] = useState([]); @@ -101,7 +113,8 @@ export default function PublishMessage() { Buffer.from(msg.text), msg.text?.length, new PublishOptions({ - type: RTM_MESSAGE_TYPE.RTM_MESSAGE_TYPE_BINARY, + channelType: channelType, + messageType: RTM_MESSAGE_TYPE.RTM_MESSAGE_TYPE_BINARY, }) ); } else { @@ -110,7 +123,8 @@ export default function PublishMessage() { msg.text, msg.text?.length, new PublishOptions({ - type: RTM_MESSAGE_TYPE.RTM_MESSAGE_TYPE_STRING, + channelType: channelType, + messageType: RTM_MESSAGE_TYPE.RTM_MESSAGE_TYPE_STRING, }) ); } @@ -123,7 +137,7 @@ export default function PublishMessage() { return; } }, - [cName, client, publishMessageByBuffer] + [cName, client, publishMessageByBuffer, channelType] ); const onSend = useCallback( @@ -224,6 +238,15 @@ export default function PublishMessage() { onChannelNameChanged={(v) => setCName(v)} onUidChanged={(v) => setUid(v)} /> + + { + setChannelType(v); + }} + title="select channelType" + value={channelType} + /> { - streamChannel?.subscribeTopic(topicName); + streamChannel?.subscribeTopic(topicName, {}); }; /** * Step 4 : unsubscribe topic */ const unsubscribe = () => { - streamChannel?.unsubscribeTopic(topicName); + streamChannel?.unsubscribeTopic(topicName, {}); setSubscribeSuccess(false); }; diff --git a/package.json b/package.json index 33add25..d59641e 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "agora-react-native-rtm", - "version": "2.1.7", + "version": "2.1.12", "description": "React Native around the Agora RTM SDKs for Android and iOS agora", "main": "lib/commonjs/index", "module": "lib/module/index", diff --git a/scripts/terra/config/impl_config.yaml b/scripts/terra/config/impl_config.yaml index 20d5085..0f25aa3 100644 --- a/scripts/terra/config/impl_config.yaml +++ b/scripts/terra/config/impl_config.yaml @@ -3,27 +3,27 @@ parsers: package: '@agoraio-extensions/cxx-parser' args: includeHeaderDirs: - - '@agoraio-extensions/terra_shared_configs:headers/rtm_2.1.7/include' + - '@agoraio-extensions/terra_shared_configs:headers/rtm_2.1.12/include' parseFiles: include: - - '@agoraio-extensions/terra_shared_configs:headers/rtm_2.1.7/include/*.h' + - '@agoraio-extensions/terra_shared_configs:headers/rtm_2.1.12/include/*.h' exclude: - - '@agoraio-extensions/terra_shared_configs:headers/rtm_2.1.7/include/IAgoraRtmService.h' - - '@agoraio-extensions/terra_shared_configs:headers/rtm_2.1.7/include/IAgoraService.h' + - '@agoraio-extensions/terra_shared_configs:headers/rtm_2.1.12/include/IAgoraRtmService.h' + - '@agoraio-extensions/terra_shared_configs:headers/rtm_2.1.12/include/IAgoraService.h' - name: AddNodeParser package: '@agoraio-extensions/terra_shared_configs' args: customHeaderFileNamePrefix: 'Custom' includeHeaderDirs: - - '@agoraio-extensions/terra_shared_configs:headers/rtm_2.1.7/include' + - '@agoraio-extensions/terra_shared_configs:headers/rtm_2.1.12/include' parseFiles: include: - - '@agoraio-extensions/terra_shared_configs:headers/rtm_2.1.7/include/*.h' - - '@agoraio-extensions/terra_shared_configs:headers/rtm_2.1.7/custom_headers/*.h' + - '@agoraio-extensions/terra_shared_configs:headers/rtm_2.1.12/include/*.h' + - '@agoraio-extensions/terra_shared_configs:headers/rtm_2.1.12/custom_headers/*.h' exclude: - - '@agoraio-extensions/terra_shared_configs:headers/rtm_2.1.7/include/IAgoraRtmService.h' - - '@agoraio-extensions/terra_shared_configs:headers/rtm_2.1.7/include/IAgoraService.h' + - '@agoraio-extensions/terra_shared_configs:headers/rtm_2.1.12/include/IAgoraRtmService.h' + - '@agoraio-extensions/terra_shared_configs:headers/rtm_2.1.12/include/IAgoraService.h' - name: RemoveNodeParser package: '@agoraio-extensions/terra_shared_configs' @@ -60,4 +60,4 @@ parsers: renderers: - path: ../impl.ts -version: 2.1.7 +version: 2.1.12 diff --git a/scripts/terra/config/types_config.yaml b/scripts/terra/config/types_config.yaml index 2360a52..0a1af7f 100644 --- a/scripts/terra/config/types_config.yaml +++ b/scripts/terra/config/types_config.yaml @@ -3,27 +3,27 @@ parsers: package: '@agoraio-extensions/cxx-parser' args: includeHeaderDirs: - - '@agoraio-extensions/terra_shared_configs:headers/rtm_2.1.7/include' + - '@agoraio-extensions/terra_shared_configs:headers/rtm_2.1.12/include' parseFiles: include: - - '@agoraio-extensions/terra_shared_configs:headers/rtm_2.1.7/include/*.h' + - '@agoraio-extensions/terra_shared_configs:headers/rtm_2.1.12/include/*.h' exclude: - - '@agoraio-extensions/terra_shared_configs:headers/rtm_2.1.7/include/IAgoraRtmService.h' - - '@agoraio-extensions/terra_shared_configs:headers/rtm_2.1.7/include/IAgoraService.h' + - '@agoraio-extensions/terra_shared_configs:headers/rtm_2.1.12/include/IAgoraRtmService.h' + - '@agoraio-extensions/terra_shared_configs:headers/rtm_2.1.12/include/IAgoraService.h' - name: AddNodeParser package: '@agoraio-extensions/terra_shared_configs' args: customHeaderFileNamePrefix: 'Custom' includeHeaderDirs: - - '@agoraio-extensions/terra_shared_configs:headers/rtm_2.1.7/include' + - '@agoraio-extensions/terra_shared_configs:headers/rtm_2.1.12/include' parseFiles: include: - - '@agoraio-extensions/terra_shared_configs:headers/rtm_2.1.7/include/*.h' - - '@agoraio-extensions/terra_shared_configs:headers/rtm_2.1.7/custom_headers/*.h' + - '@agoraio-extensions/terra_shared_configs:headers/rtm_2.1.12/include/*.h' + - '@agoraio-extensions/terra_shared_configs:headers/rtm_2.1.12/custom_headers/*.h' exclude: - - '@agoraio-extensions/terra_shared_configs:headers/rtm_2.1.7/include/IAgoraRtmService.h' - - '@agoraio-extensions/terra_shared_configs:headers/rtm_2.1.7/include/IAgoraService.h' + - '@agoraio-extensions/terra_shared_configs:headers/rtm_2.1.12/include/IAgoraRtmService.h' + - '@agoraio-extensions/terra_shared_configs:headers/rtm_2.1.12/include/IAgoraService.h' - name: RemoveNodeParser package: '@agoraio-extensions/terra_shared_configs' @@ -64,4 +64,4 @@ parsers: renderers: - path: ../index.ts -version: 2.1.7 +version: 2.1.12 diff --git a/src/AgoraRtmBase.ts b/src/AgoraRtmBase.ts index 9a75e3f..30f270a 100644 --- a/src/AgoraRtmBase.ts +++ b/src/AgoraRtmBase.ts @@ -300,6 +300,10 @@ export enum RTM_ERROR_CODE { * -11032: The channel presence is not ready. */ RTM_ERROR_CHANNEL_PRESENCE_NOT_READY = -11032, + /** + * -11033: The destination user of publish message is offline. + */ + RTM_ERROR_CHANNEL_RECEIVER_OFFLINE = -11033, /** * -12001 ~ -13000 : reserved for storage error. * -12001: The storage operation failed. @@ -628,6 +632,10 @@ export enum RTM_CHANNEL_TYPE { * 2: Stream channel. */ RTM_CHANNEL_TYPE_STREAM = 2, + /** + * 3: User. + */ + RTM_CHANNEL_TYPE_USER = 3, } /** @@ -735,6 +743,10 @@ export enum RTM_PROXY_TYPE { * 1: Link with http proxy */ RTM_PROXY_TYPE_HTTP = 1, + /** + * 2: Link with tcp cloud proxy + */ + RTM_PROXY_TYPE_CLOUD_TCP = 2, } /** @@ -1083,10 +1095,34 @@ export class GetOnlineUsersOptions { * @brief Publish message option */ export class PublishOptions { + channelType?: RTM_CHANNEL_TYPE = RTM_CHANNEL_TYPE.RTM_CHANNEL_TYPE_MESSAGE; + /** + * The message type. + */ + messageType?: RTM_MESSAGE_TYPE = RTM_MESSAGE_TYPE.RTM_MESSAGE_TYPE_BINARY; + /** + * The custom type of the message, up to 32 bytes for customize + */ + customType?: string; + constructor( + props?: Partial<{ + channelType?: RTM_CHANNEL_TYPE; + messageType?: RTM_MESSAGE_TYPE; + customType?: string; + }> + ) { + Object.assign(this, props); + } +} + +/** + * @brief topic message option + */ +export class TopicMessageOptions { /** * The message type. */ - type?: RTM_MESSAGE_TYPE = RTM_MESSAGE_TYPE.RTM_MESSAGE_TYPE_BINARY; + messageType?: RTM_MESSAGE_TYPE = RTM_MESSAGE_TYPE.RTM_MESSAGE_TYPE_BINARY; /** * The time to calibrate data with media, * only valid when user join topic with syncWithMedia in stream channel @@ -1098,7 +1134,7 @@ export class PublishOptions { customType?: string; constructor( props?: Partial<{ - type?: RTM_MESSAGE_TYPE; + messageType?: RTM_MESSAGE_TYPE; sendTs?: number; customType?: string; }> diff --git a/src/IAgoraStreamChannel.ts b/src/IAgoraStreamChannel.ts index ceb7b28..9df7f11 100644 --- a/src/IAgoraStreamChannel.ts +++ b/src/IAgoraStreamChannel.ts @@ -1,4 +1,4 @@ -import { PublishOptions, UserList } from './AgoraRtmBase'; +import { PublishOptions, TopicMessageOptions, UserList } from './AgoraRtmBase'; /// Generated by terra, DO NOT MODIFY BY HAND. @@ -192,7 +192,7 @@ export abstract class IStreamChannel { topic: string, message: string, length: number, - option: PublishOptions + option: TopicMessageOptions ): number; /** * Leave the topic. diff --git a/src/impl/IAgoraStreamChannelImpl.ts b/src/impl/IAgoraStreamChannelImpl.ts index 9e2086a..4cba420 100644 --- a/src/impl/IAgoraStreamChannelImpl.ts +++ b/src/impl/IAgoraStreamChannelImpl.ts @@ -1,4 +1,4 @@ -import { PublishOptions, UserList } from '../AgoraRtmBase'; +import { PublishOptions, TopicMessageOptions, UserList } from '../AgoraRtmBase'; import { IStreamChannel, JoinChannelOptions, @@ -96,7 +96,7 @@ export class IStreamChannelImpl implements IStreamChannel { topic: string, message: string, length: number, - option: PublishOptions + option: TopicMessageOptions ): number { const apiType = this.getApiTypeFromPublishTopicMessage( topic, @@ -126,7 +126,7 @@ export class IStreamChannelImpl implements IStreamChannel { topic: string, message: string, length: number, - option: PublishOptions + option: TopicMessageOptions ): string { return 'StreamChannel_publishTopicMessage'; }