Browse Source

移除自动新建数据流通道的支持,以便使用者按需自主创建

Riant 6 years ago
parent
commit
ea9b02e923
2 changed files with 2 additions and 9 deletions
  1. 1
    3
      android/src/main/java/com/syan/agora/AgoraModule.java
  2. 1
    6
      ios/RCTAgora/RCTAgora.m

+ 1
- 3
android/src/main/java/com/syan/agora/AgoraModule.java View File

@@ -21,7 +21,6 @@ import io.agora.rtc.RtcEngine;
21 21
 import static com.facebook.react.bridge.UiThreadUtil.runOnUiThread;
22 22
 
23 23
 public class AgoraModule extends ReactContextBaseJavaModule {
24
-    private int defaultStreamId = -1;
25 24
 
26 25
     public AgoraModule(ReactApplicationContext context) {
27 26
 
@@ -206,7 +205,6 @@ public class AgoraModule extends ReactContextBaseJavaModule {
206 205
     @ReactMethod
207 206
     public void init(ReadableMap options) {
208 207
         AgoraManager.getInstance().init(getReactApplicationContext(), mRtcEventHandler, options);
209
-        this.defaultStreamId = AgoraManager.getInstance().mRtcEngine.createDataStream(false, false);
210 208
     }
211 209
 
212 210
     //进入房间
@@ -375,7 +373,7 @@ public class AgoraModule extends ReactContextBaseJavaModule {
375 373
     // 发送数据
376 374
     @ReactMethod
377 375
     public void sendStreamMessage(int streamId, String message, Callback onError) {
378
-        onError.invoke(AgoraManager.getInstance().mRtcEngine.sendStreamMessage(streamId > 0 ? streamId : this.defaultStreamId, message.getBytes()));
376
+        onError.invoke(AgoraManager.getInstance().mRtcEngine.sendStreamMessage(streamId, message.getBytes()));
379 377
     }
380 378
 
381 379
     //销毁引擎实例

+ 1
- 6
ios/RCTAgora/RCTAgora.m View File

@@ -34,8 +34,6 @@ RCT_EXPORT_MODULE();
34 34
     return @{};
35 35
 }
36 36
 
37
-NSInteger defaultDataStreamId = -1;
38
-
39 37
 /**
40 38
  *  初始化AgoraKit
41 39
  *
@@ -64,9 +62,6 @@ RCT_EXPORT_METHOD(init:(NSDictionary *)options) {
64 62
     [self.rtcEngine setVideoProfile:[options[@"videoProfile"] integerValue]swapWidthAndHeight:[options[@"swapWidthAndHeight"]boolValue]];
65 63
     [self.rtcEngine setClientRole:[options[@"clientRole"] integerValue] withKey:nil];
66 64
 
67
-    // 创建默认数据通道
68
-    [self.rtcEngine createDataStream:&dataChannelId reliable:0 ordered:0];
69
-
70 65
     //Agora Native SDK 与 Agora Web SDK 间的互通
71 66
     [self.rtcEngine enableWebSdkInteroperability:YES];
72 67
 
@@ -255,7 +250,7 @@ RCT_EXPORT_METHOD(createDataStream:(BOOL)reliable ordered:(BOOL)ordered callback
255 250
 发送数据流
256 251
 */
257 252
 RCT_EXPORT_METHOD(sendStreamMessage:(NSInteger)streamId data:(NSData*)data callback:(RCTResponseSenderBlock)callback){
258
-  int err = [self.rtcEngine sendStreamMessage:(streamId > 0 ? streamId : defaultDataStreamId) data:data];
253
+  int err = [self.rtcEngine sendStreamMessage:(streamId) data:data];
259 254
   callback(@[[NSNumber numberWithInteger:err]]);
260 255
 }
261 256