@@ -31,19 +31,72 @@ typedef struct _LDClientSDK* LDClientSDK;
31
31
LD_EXPORT (LDClientSDK )
32
32
LDClientSDK_New (LDClientConfig config , LDContext context );
33
33
34
+ /**
35
+ * Starts the SDK, initiating a connection to LaunchDarkly if not offline.
36
+ *
37
+ * Only one Start call can be in progress at once; calling it
38
+ * concurrently invokes undefined behavior.
39
+ *
40
+ * The method may be blocking or asynchronous depending on the arguments.
41
+ *
42
+ * To block, pass a positive milliseconds value and an optional pointer to a
43
+ boolean. The return
44
+ * value will be true if the SDK started within the specified timeframe, or
45
+ false if the
46
+ * operation couldn't complete in time. The value of out_succeeded will be true
47
+ * if the SDK successfully initialized.
48
+ *
49
+ * Example:
50
+ * @code
51
+ * bool initialized_successfully;
52
+ * if (LDClientSDK_Start(client, 5000, &initialized_successfully)) {
53
+ * // The client was able to initialize in less than 5 seconds.
54
+ * if (initialized_successfully) {
55
+ * // Initialization succeeded.
56
+ * else {
57
+ * // Initialization failed.
58
+ * }
59
+ * } else {
60
+ * // The client is still initializing.
61
+ * }
62
+ * @endcode
63
+ *
64
+ * To start asynchronously, pass `LD_NONBLOCKING`. In this case, the return
65
+ value
66
+ * will be false and you may pass NULL to out_succeeded.
67
+ *
68
+ * @code
69
+ * // Returns immediately.
70
+ * LDClientSDK_Start(client, LD_NONBLOCKING, NULL);
71
+ * @endcode
72
+ *
73
+ * @param sdk SDK. Must not be NULL.
74
+ * @param milliseconds Milliseconds to wait for initialization or
75
+ `LD_NONBLOCKING` to return immediately.
76
+ * @param out_succeeded Pointer to bool representing successful initialization.
77
+ Only
78
+ * modified if a positive milliseconds value is passed; may be NULL.
79
+ * @return True if the client started within the specified timeframe.
80
+ */
81
+ LD_EXPORT (bool )
82
+ LDClientSDK_Start (LDClientSDK sdk ,
83
+ unsigned int milliseconds ,
84
+ bool * out_succeeded );
85
+
34
86
/**
35
87
* Returns a boolean value indicating LaunchDarkly connection and flag state
36
88
* within the client.
37
89
*
38
- * When you first start the client, once WaitForReadySync has returned or
39
- * WaitForReadyAsync has completed, Initialized should return true if
40
- * and only if either 1. it connected to LaunchDarkly and successfully
41
- * retrieved flags, or 2. it started in offline mode so there's no need to
42
- * connect to LaunchDarkly. If the client timed out trying to connect to LD,
43
- * then Initialized returns false (even if we do have cached flags).
44
- * If the client connected and got a 401 error, Initialized is
45
- * will return false. This serves the purpose of letting the app know that
46
- * there was a problem of some kind.
90
+ * When you first start the client, once Start has completed, Initialized
91
+ * should return true if and only if either 1. it connected to LaunchDarkly and
92
+ * successfully retrieved flags, or 2. it started in offline mode so there's no
93
+ * need to connect to LaunchDarkly.
94
+ *
95
+ * If the client timed out trying to connect to
96
+ * LD, then Initialized returns false (even if we do have cached flags). If the
97
+ * client connected and got a 401 error, Initialized is will return false. This
98
+ * serves the purpose of letting the app know that there was a problem of some
99
+ * kind.
47
100
*
48
101
* @param sdk SDK. Must not be NULL.
49
102
* @return True if initialized.
@@ -89,10 +142,10 @@ LDClientSDK_TrackData(LDClientSDK sdk, char const* event_name, LDValue data);
89
142
/**
90
143
* Requests delivery of all pending analytic events (if any).
91
144
*
92
- * You MUST pass LD_NONBLOCKING as the second parameter.
145
+ * You MUST pass ` LD_NONBLOCKING` as the second parameter.
93
146
*
94
147
* @param sdk SDK. Must not be NULL.
95
- * @param milliseconds Must pass LD_NONBLOCKING.
148
+ * @param milliseconds Must pass ` LD_NONBLOCKING` .
96
149
*/
97
150
LD_EXPORT (void )
98
151
LDClientSDK_Flush (LDClientSDK sdk , unsigned int reserved );
@@ -105,19 +158,54 @@ LDClientSDK_Flush(LDClientSDK sdk, unsigned int reserved);
105
158
* Only one Identify call can be in progress at once; calling it
106
159
* concurrently invokes undefined behavior.
107
160
*
108
- * To block until the identify operation is complete or a timeout is reached,
109
- * pass a positive milliseconds parameter. Otherwise to return immediately,
110
- * pass LD_NONBLOCKING.
161
+ * The method may be blocking or asynchronous depending on the arguments.
162
+ *
163
+ * To block, pass a positive milliseconds value and an optional pointer to a
164
+ boolean. The return
165
+ * value will be true if the SDK was able to attempt the operation within
166
+ the specified timeframe, or false if the
167
+ * operation couldn't complete in time. The value of out_succeeded will be true
168
+ * if the SDK successfully changed evaluation contexts.
169
+ *
170
+ * Example:
171
+ * @code
172
+ * bool identified_successfully;
173
+ * if (LDClientSDK_Identify(client, 5000, &identified_successfully)) {
174
+ * // The client was able to re-initialize in less than 5 seconds.
175
+ * if (identified_successfully) {
176
+ * // Evaluations will use data for the new context.
177
+ * else {
178
+ * // Evaluations will continue using existing data.
179
+ * }
180
+ * } else {
181
+ * // The client is still identifying.
182
+ * }
183
+ * @endcode
184
+ *
185
+ * To start asynchronously, pass `LD_NONBLOCKING`. In this case, the return
186
+ value
187
+ * will be false and you may pass NULL to out_succeeded.
188
+ *
189
+ * @code
190
+ * // Returns immediately.
191
+ * LDClientSDK_Identify(client, LD_NONBLOCKING, NULL);
192
+ * @endcode
193
+ *
111
194
*
112
195
* @param sdk SDK. Must not be NULL.
113
196
* @param context The new evaluation context.
114
- * @param milliseconds How long to wait for the identify to complete, or
115
- * LD_NONBLOCKING to return immediately.
197
+ * @param milliseconds Milliseconds to wait for identify to complete, or
198
+ * `LD_NONBLOCKING` to return immediately.
199
+ * @param out_succeeded Pointer to bool representing successful identification.
200
+ Only
201
+ * modified if a positive milliseconds value is passed; may be NULL.
202
+ * @return True if the client started within the specified timeframe.
116
203
*/
117
- LD_EXPORT (void )
204
+ LD_EXPORT (bool )
118
205
LDClientSDK_Identify (LDClientSDK sdk ,
119
206
LDContext context ,
120
- unsigned int milliseconds );
207
+ unsigned int milliseconds ,
208
+ bool * out_succeeded );
121
209
122
210
/**
123
211
* Returns the boolean value of a feature flag for a given flag key.
0 commit comments