浏览代码

rn: refactor conference events

Consolidate all failure cases into a single one: CONFERENCE_TERMINATED. If the
conference ended gracefully no error indicator will be present, otherwise there
will be.
master
Saúl Ibarra Corretgé 6 年前
父节点
当前提交
d39290f9fa

+ 6
- 29
android/README.md 查看文件

@@ -376,29 +376,20 @@ This is a static method.
376 376
 `JitsiMeetViewListener` provides an interface apps can implement to listen to
377 377
 the state of the Jitsi Meet conference displayed in a `JitsiMeetView`.
378 378
 
379
-`JitsiMeetViewAdapter`, a default implementation of the
380
-`JitsiMeetViewListener` interface is also provided. Apps may extend the class
381
-instead of implementing the interface in order to minimize boilerplate.
382
-
383
-##### onConferenceFailed
384
-
385
-Called when a joining a conference was unsuccessful or when there was an error
386
-while in a conference.
387
-
388
-The `data` `Map` contains an "error" key describing the error and a "url" key
389
-with the conference URL.
390
-
391 379
 #### onConferenceJoined
392 380
 
393 381
 Called when a conference was joined.
394 382
 
395 383
 The `data` `Map` contains a "url" key with the conference URL.
396 384
 
397
-#### onConferenceLeft
385
+#### onConferenceTerminated
398 386
 
399
-Called when a conference was left.
387
+Called when a conference was terminated either by user choice or due to a
388
+failure.
400 389
 
401
-The `data` `Map` contains a "url" key with the conference URL.
390
+The `data` `Map` contains an "error" key with the error and a "url" key
391
+with the conference URL. If the conference finished gracefully no `error`
392
+key will be present.
402 393
 
403 394
 #### onConferenceWillJoin
404 395
 
@@ -406,20 +397,6 @@ Called before a conference is joined.
406 397
 
407 398
 The `data` `Map` contains a "url" key with the conference URL.
408 399
 
409
-#### onConferenceWillLeave
410
-
411
-Called before a conference is left.
412
-
413
-The `data` `Map` contains a "url" key with the conference URL.
414
-
415
-#### onLoadConfigError
416
-
417
-Called when loading the main configuration file from the Jitsi Meet deployment
418
-fails.
419
-
420
-The `data` `Map` contains an "error" key with the error and a "url" key with the
421
-conference URL which necessitated the loading of the configuration file.
422
-
423 400
 ## ProGuard rules
424 401
 
425 402
 When using the SDK on a project some proguard rules have to be added in order

+ 2
- 12
android/app/src/main/java/org/jitsi/meet/MainActivity.java 查看文件

@@ -107,18 +107,8 @@ public class MainActivity extends JitsiMeetActivity {
107 107
     }
108 108
 
109 109
     @Override
110
-    public void onConferenceFailed(Map<String, Object> data) {
111
-        Log.d(TAG, "Conference failed: " + data);
112
-    }
113
-
114
-    @Override
115
-    public void onConferenceLeft(Map<String, Object> data) {
116
-        Log.d(TAG, "Conference left: " + data);
117
-    }
118
-
119
-    @Override
120
-    public void onLoadConfigError(Map<String, Object> data) {
121
-        Log.d(TAG, "Error loading config: " + data);
110
+    public void onConferenceTerminated(Map<String, Object> data) {
111
+        Log.d(TAG, "Conference terminated: " + data);
122 112
     }
123 113
 
124 114
     // Activity lifecycle method overrides

+ 2
- 19
android/sdk/src/main/java/org/jitsi/meet/sdk/JitsiMeetActivity.java 查看文件

@@ -154,20 +154,14 @@ public class JitsiMeetActivity extends FragmentActivity
154 154
     // JitsiMeetViewListener
155 155
     //
156 156
 
157
-    @Override
158
-    public void onConferenceFailed(Map<String, Object> data) {
159
-        Log.d(TAG, "Conference failed: " + data);
160
-        finish();
161
-    }
162
-
163 157
     @Override
164 158
     public void onConferenceJoined(Map<String, Object> data) {
165 159
         Log.d(TAG, "Conference joined: " + data);
166 160
     }
167 161
 
168 162
     @Override
169
-    public void onConferenceLeft(Map<String, Object> data) {
170
-        Log.d(TAG, "Conference left: " + data);
163
+    public void onConferenceTerminated(Map<String, Object> data) {
164
+        Log.d(TAG, "Conference terminated: " + data);
171 165
         finish();
172 166
     }
173 167
 
@@ -175,15 +169,4 @@ public class JitsiMeetActivity extends FragmentActivity
175 169
     public void onConferenceWillJoin(Map<String, Object> data) {
176 170
         Log.d(TAG, "Conference will join: " + data);
177 171
     }
178
-
179
-    @Override
180
-    public void onConferenceWillLeave(Map<String, Object> data) {
181
-        Log.d(TAG, "Conference will leave: " + data);
182
-    }
183
-
184
-    @Override
185
-    public void onLoadConfigError(Map<String, Object> data) {
186
-        Log.d(TAG, "Error loading config: " + data);
187
-        finish();
188
-    }
189 172
 }

+ 1
- 3
android/sdk/src/main/java/org/jitsi/meet/sdk/JitsiMeetView.java 查看文件

@@ -186,9 +186,7 @@ public class JitsiMeetView extends BaseReactView<JitsiMeetViewListener> {
186 186
             this.url = url;
187 187
             break;
188 188
 
189
-        case "CONFERENCE_FAILED":
190
-        case "CONFERENCE_WILL_LEAVE":
191
-        case "LOAD_CONFIG_ERROR":
189
+        case "CONFERENCE_TERMINATED":
192 190
             if (url != null && url.equals(this.url)) {
193 191
                 this.url = null;
194 192
             }

+ 6
- 29
android/sdk/src/main/java/org/jitsi/meet/sdk/JitsiMeetViewListener.java 查看文件

@@ -22,15 +22,6 @@ import java.util.Map;
22 22
  * Interface for listening to events coming from Jitsi Meet.
23 23
  */
24 24
 public interface JitsiMeetViewListener {
25
-    /**
26
-     * Called when joining a conference fails or an ongoing conference is
27
-     * interrupted due to a failure.
28
-     *
29
-     * @param data Map with an "error" key describing the problem, and a "url"
30
-     * key with the conference URL.
31
-     */
32
-    void onConferenceFailed(Map<String, Object> data);
33
-
34 25
     /**
35 26
      * Called when a conference was joined.
36 27
      *
@@ -39,11 +30,14 @@ public interface JitsiMeetViewListener {
39 30
     void onConferenceJoined(Map<String, Object> data);
40 31
 
41 32
     /**
42
-     * Called when the conference was left, typically after hanging up.
33
+     * Called when the active conference ends, be it because of user choice or
34
+     * because of a failure.
43 35
      *
44
-     * @param data Map with a "url" key with the conference URL.
36
+     * @param data Map with an "error" key with the error and a "url" key with
37
+     * the conference URL. If the conference finished gracefully no `error`
38
+     * key will be present.
45 39
      */
46
-    void onConferenceLeft(Map<String, Object> data);
40
+    void onConferenceTerminated(Map<String, Object> data);
47 41
 
48 42
     /**
49 43
      * Called before the conference is joined.
@@ -51,21 +45,4 @@ public interface JitsiMeetViewListener {
51 45
      * @param data Map with a "url" key with the conference URL.
52 46
      */
53 47
     void onConferenceWillJoin(Map<String, Object> data);
54
-
55
-    /**
56
-     * Called before the conference is left.
57
-     *
58
-     * @param data Map with a "url" key with the conference URL.
59
-     */
60
-    void onConferenceWillLeave(Map<String, Object> data);
61
-
62
-    /**
63
-     * Called when loading the main configuration file from the Jitsi Meet
64
-     * deployment fails.
65
-     *
66
-     * @param data Map with an "error" key with the error and a "url" key with
67
-     * the conference URL which necessitated the loading of the configuration
68
-     * file.
69
-     */
70
-    void onLoadConfigError(Map<String, Object> data);
71 48
 }

+ 6
- 26
ios/README.md 查看文件

@@ -128,25 +128,20 @@ fail?
128 128
 
129 129
 All methods in this delegate are optional.
130 130
 
131
-##### conferenceFailed
132
-
133
-Called when a joining a conference was unsuccessful or when there was an error
134
-while in a conference.
135
-
136
-The `data` dictionary contains an "error" key describing the error and a "url"
137
-key with the conference URL.
138
-
139 131
 #### conferenceJoined
140 132
 
141 133
 Called when a conference was joined.
142 134
 
143 135
 The `data` dictionary contains a "url" key with the conference URL.
144 136
 
145
-#### conferenceLeft
137
+#### conferenceTerminated
146 138
 
147
-Called when a conference was left.
139
+Called when a conference was terminated either by user choice or due to a
140
+failure.
148 141
 
149
-The `data` dictionary contains a "url" key with the conference URL.
142
+The `data` dictionary contains an "error" key with the error and a "url" key
143
+with the conference URL. If the conference finished gracefully no `error`
144
+key will be present.
150 145
 
151 146
 #### conferenceWillJoin
152 147
 
@@ -154,12 +149,6 @@ Called before a conference is joined.
154 149
 
155 150
 The `data` dictionary contains a "url" key with the conference URL.
156 151
 
157
-#### conferenceWillLeave
158
-
159
-Called before a conference is left.
160
-
161
-The `data` dictionary contains a "url" key with the conference URL.
162
-
163 152
 #### enterPictureInPicture
164 153
 
165 154
 Called when entering Picture-in-Picture is requested by the user. The app should
@@ -170,15 +159,6 @@ associated with Picture-in-Picture.)
170 159
 
171 160
 The `data` dictionary is empty.
172 161
 
173
-#### loadConfigError
174
-
175
-Called when loading the main configuration file from the Jitsi Meet deployment
176
-fails.
177
-
178
-The `data` dictionary contains an "error" key with the error and a "url" key
179
-with the conference URL which necessitated the loading of the configuration
180
-file.
181
-
182 162
 ### Picture-in-Picture
183 163
 
184 164
 `JitsiMeetView` will automatically adjust its UI when presented in a

+ 2
- 14
ios/app/src/ViewController.m 查看文件

@@ -54,10 +54,6 @@
54 54
 #endif
55 55
 }
56 56
 
57
-- (void)conferenceFailed:(NSDictionary *)data {
58
-    [self _onJitsiMeetViewDelegateEvent:@"CONFERENCE_FAILED" withData:data];
59
-}
60
-
61 57
 - (void)conferenceJoined:(NSDictionary *)data {
62 58
     [self _onJitsiMeetViewDelegateEvent:@"CONFERENCE_JOINED" withData:data];
63 59
 
@@ -92,20 +88,12 @@
92 88
 
93 89
 }
94 90
 
95
-- (void)conferenceLeft:(NSDictionary *)data {
96
-    [self _onJitsiMeetViewDelegateEvent:@"CONFERENCE_LEFT" withData:data];
91
+- (void)conferenceTerminated:(NSDictionary *)data {
92
+    [self _onJitsiMeetViewDelegateEvent:@"CONFERENCE_TERMINATED" withData:data];
97 93
 }
98 94
 
99 95
 - (void)conferenceWillJoin:(NSDictionary *)data {
100 96
     [self _onJitsiMeetViewDelegateEvent:@"CONFERENCE_WILL_JOIN" withData:data];
101 97
 }
102 98
 
103
-- (void)conferenceWillLeave:(NSDictionary *)data {
104
-    [self _onJitsiMeetViewDelegateEvent:@"CONFERENCE_WILL_LEAVE" withData:data];
105
-}
106
-
107
-- (void)loadConfigError:(NSDictionary *)data {
108
-    [self _onJitsiMeetViewDelegateEvent:@"LOAD_CONFIG_ERROR" withData:data];
109
-}
110
-
111 99
 @end

+ 6
- 29
ios/sdk/src/JitsiMeetViewDelegate.h 查看文件

@@ -18,15 +18,6 @@
18 18
 
19 19
 @optional
20 20
 
21
-/**
22
- * Called when a joining a conference was unsuccessful or when there was an
23
- * error while in a conference.
24
- *
25
- * The `data` dictionary contains an `error` key describing the error and a
26
- * `url` key with the conference URL.
27
- */
28
-- (void)conferenceFailed:(NSDictionary *)data;
29
-
30 21
 /**
31 22
  * Called when a conference was joined.
32 23
  *
@@ -35,11 +26,14 @@
35 26
 - (void)conferenceJoined:(NSDictionary *)data;
36 27
 
37 28
 /**
38
- * Called when a conference was left.
29
+ * Called when the active conference ends, be it because of user choice or
30
+ * because of a failure.
39 31
  *
40
- * The `data` dictionary contains a `url` key with the conference URL.
32
+ * The `data` dictionary contains an `error` key with the error and a `url` key
33
+ * with the conference URL. If the conference finished gracefully no `error`
34
+ * key will be present.
41 35
  */
42
-- (void)conferenceLeft:(NSDictionary *)data;
36
+- (void)conferenceTerminated:(NSDictionary *)data;
43 37
 
44 38
 /**
45 39
  * Called before a conference is joined.
@@ -48,13 +42,6 @@
48 42
  */
49 43
 - (void)conferenceWillJoin:(NSDictionary *)data;
50 44
 
51
-/**
52
- * Called before a conference is left.
53
- *
54
- * The `data` dictionary contains a `url` key with the conference URL.
55
- */
56
-- (void)conferenceWillLeave:(NSDictionary *)data;
57
-
58 45
 /**
59 46
  * Called when entering Picture-in-Picture is requested by the user. The app
60 47
  * should now activate its Picture-in-Picture implementation (and resize the
@@ -66,14 +53,4 @@
66 53
  */
67 54
 - (void)enterPictureInPicture:(NSDictionary *)data;
68 55
 
69
-/**
70
- * Called when loading the main configuration file from the Jitsi Meet
71
- * deployment file.
72
- *
73
- * The `data` dictionary contains an `error` key with the error and a `url` key
74
- * with the conference URL which necessitated the loading of the configuration
75
- * file.
76
- */
77
-- (void)loadConfigError:(NSDictionary *)data;
78
-
79 56
 @end

+ 26
- 7
react/features/mobile/external-api/middleware.js 查看文件

@@ -5,7 +5,6 @@ import {
5 5
     CONFERENCE_JOINED,
6 6
     CONFERENCE_LEFT,
7 7
     CONFERENCE_WILL_JOIN,
8
-    CONFERENCE_WILL_LEAVE,
9 8
     JITSI_CONFERENCE_URL_KEY,
10 9
     SET_ROOM,
11 10
     forEachConference,
@@ -19,6 +18,12 @@ import { ENTER_PICTURE_IN_PICTURE } from '../picture-in-picture';
19 18
 
20 19
 import { sendEvent } from './functions';
21 20
 
21
+/**
22
+ * Event which will be emitted on the native side to indicate the conference
23
+ * has ended either by user request or because an error was produced.
24
+ */
25
+const CONFERENCE_TERMINATED = 'CONFERENCE_TERMINATED';
26
+
22 27
 /**
23 28
  * Middleware that captures Redux actions and uses the ExternalAPI module to
24 29
  * turn them into native events so the application knows about them.
@@ -55,7 +60,6 @@ MiddlewareRegistry.register(store => next => action => {
55 60
     case CONFERENCE_JOINED:
56 61
     case CONFERENCE_LEFT:
57 62
     case CONFERENCE_WILL_JOIN:
58
-    case CONFERENCE_WILL_LEAVE:
59 63
         _sendConferenceEvent(store, action);
60 64
         break;
61 65
 
@@ -73,7 +77,7 @@ MiddlewareRegistry.register(store => next => action => {
73 77
 
74 78
         sendEvent(
75 79
             store,
76
-            getSymbolDescription(type),
80
+            CONFERENCE_TERMINATED,
77 81
             /* data */ {
78 82
                 error: _toErrorString(error),
79 83
                 url: toURLString(locationURL)
@@ -159,12 +163,27 @@ function _sendConferenceEvent(
159 163
         data.url = toURLString(conference[JITSI_CONFERENCE_URL_KEY]);
160 164
     }
161 165
 
162
-    _swallowEvent(store, action, data)
163
-        || sendEvent(store, getSymbolDescription(type), data);
166
+    if (_swallowEvent(store, action, data)) {
167
+        return;
168
+    }
169
+
170
+    let type_;
171
+
172
+    switch (type) {
173
+    case CONFERENCE_FAILED:
174
+    case CONFERENCE_LEFT:
175
+        type_ = CONFERENCE_TERMINATED;
176
+        break;
177
+    default:
178
+        type_ = getSymbolDescription(type);
179
+        break;
180
+    }
181
+
182
+    sendEvent(store, type_, data);
164 183
 }
165 184
 
166 185
 /**
167
- * Sends {@link CONFERENCE_FAILED} event when the {@link CONNECTION_FAILED}
186
+ * Sends {@link CONFERENCE_TERMINATED} event when the {@link CONNECTION_FAILED}
168 187
  * occurs. It should be done only if the connection fails before the conference
169 188
  * instance is created. Otherwise the eventual failure event is supposed to be
170 189
  * emitted by the base/conference feature.
@@ -186,7 +205,7 @@ function _sendConferenceFailedOnConnectionError(store, action) {
186 205
             conference => conference.getConnection() !== connection)
187 206
         && sendEvent(
188 207
         store,
189
-        getSymbolDescription(CONFERENCE_FAILED),
208
+        CONFERENCE_TERMINATED,
190 209
         /* data */ {
191 210
             url: toURLString(locationURL),
192 211
             error: action.error.name

正在加载...
取消
保存