@@ -34,6 +34,7 @@ export const initialState = {
34
34
isDisconnected : false ,
35
35
isConnected : false ,
36
36
initData : null ,
37
+ connected : [ ]
37
38
} ;
38
39
39
40
@@ -43,8 +44,8 @@ const mobileData = {
43
44
fields : [ ] ,
44
45
values : [ ] ,
45
46
setters : [ ] ,
46
- clients : [ ] ,
47
- client : null ,
47
+ senders : [ ] ,
48
+ sender : null ,
48
49
mobileConfig : null
49
50
} ;
50
51
@@ -180,39 +181,41 @@ const buildMobileConfig = (initData, options, notify) => {
180
181
notify ( { type : ACTION_TYPES . REGISTER_FAILED , errorMessage } ) ;
181
182
182
183
} ,
183
- onSenderConnected : ( client , clients ) => {
184
+ onSenderConnected : ( sender , senders ) => {
184
185
mobileData . mobileState = MobileState . MOBILE_CONNECTED ;
185
- mobileData . clients = clients ;
186
- mobileData . client = client ;
187
- options && options . onSenderConnected && options . onSenderConnected ( client , clients ) ;
186
+ mobileData . senders = senders ;
187
+ mobileData . sender = sender ;
188
+ options && options . onSenderConnected && options . onSenderConnected ( sender , senders ) ;
188
189
notify ( { type : ACTION_TYPES . SENDER_CONNECTED } ) ;
189
190
} ,
190
- onSenderDisconnected : ( client , clients ) => {
191
- mobileData . clients = clients ;
192
- mobileData . client = client ;
193
- if ( clients && clients . length ) {
194
- console . log ( "-multi-client -" ) ;
191
+ onSenderDisconnected : ( sender , senders ) => {
192
+ mobileData . senders = senders ;
193
+ mobileData . sender = sender ;
194
+ if ( senders && senders . length ) {
195
+ console . log ( "-multi-senders -" ) ;
195
196
}
196
197
else {
197
198
mobileData . mobileState = MobileState . INITIALIZING ;
198
199
mobileData . session . connect ( mobileData . mobileConfig ) ;
199
- console . log ( "-client -disconnected-" ) ;
200
+ console . log ( "-sender -disconnected-" ) ;
200
201
}
201
- options && options . onSenderDisconnected && options . onSenderDisconnected ( client , clients ) ;
202
+ options && options . onSenderDisconnected && options . onSenderDisconnected ( sender , senders ) ;
202
203
notify ( { type : ACTION_TYPES . SENDER_DISCONNECTED } ) ;
203
204
204
205
} ,
206
+ onInputPermission : ( permissionMessage , senders , deny ) => {
207
+ if ( options && options . onInputPermission ) {
208
+ options . onInputPermission ( permissionMessage , senders , deny ) ;
209
+ }
210
+ } ,
205
211
onError : errorMessage => {
206
212
closeConnection ( ) ;
207
213
mobileData . mobileState = MobileState . ERROR ;
208
214
notify ( { type : ACTION_TYPES . CONNECTION_ERROR , errorMessage } ) ;
209
215
} ,
210
216
url : options && options . url ,
211
217
apikey : options && options . apikey ,
212
- securityGroup : options && options . securityGroup ,
213
- aes : options && options . aes ,
214
- onInput : options && options . onInput ,
215
- onInputPermissionResult : options && options . onInputPermissionResult
218
+ securityGroup : options && options . securityGroup
216
219
} ;
217
220
} ;
218
221
@@ -242,14 +245,16 @@ export const startConnect = (config, configId, notify) => {
242
245
if ( ! mobileData . session ) {
243
246
mobileData . session = createMessageConnector ( ) ;
244
247
}
245
- if ( config . codeAES ) {
248
+ if ( config . codeAES ) {
246
249
mobileData . session . setCodeAES ( config . codeAES ) ;
247
250
}
248
251
mobileData . session . connect ( mobileData . mobileConfig ) ;
249
252
notify ( { type : ACTION_TYPES . START_CONNECT } ) ;
250
253
} ;
251
254
252
-
255
+ export const getParingCode = ( ) => {
256
+ return mobileData . session && mobileData . session . buildPairingData ( ) ;
257
+ } ;
253
258
254
259
255
260
export const reducer = ( state , action ) => {
@@ -281,7 +286,8 @@ export const reducer = (state, action) => {
281
286
isError : mobileData . mobileState === MobileState . ERROR ,
282
287
isDisconnected : mobileData . mobileState === MobileState . DISCONNECTED ,
283
288
isConnected : mobileData . mobileState === MobileState . MOBILE_CONNECTED ,
284
- initData : mobileData . mobileConfig && mobileData . mobileConfig . initData
289
+ initData : mobileData . mobileConfig && mobileData . mobileConfig . initData ,
290
+ senders : mobileData . senders
285
291
} ;
286
292
} ;
287
293
@@ -307,22 +313,22 @@ export const qrCodeLabel = (
307
313
</ div >
308
314
) ;
309
315
310
- export const displayQRCode = ( connectionCode , level , size , label , maxSize , marginTop , marginLeft ) => {
311
- if ( ( ! connectionCode ) || size === 0 ) {
316
+ export const displayQRCode = ( codeContent , level , size , label , maxSize , marginTop , marginLeft ) => {
317
+ if ( ( ! codeContent ) || size === 0 ) {
312
318
return null ;
313
319
}
314
320
if ( size ) {
315
321
return (
316
322
< >
317
- < QRCode value = { connectionCode } level = { level } size = { size } />
323
+ < QRCode value = { codeContent } level = { level } size = { size } />
318
324
{ label }
319
325
</ >
320
326
) ;
321
327
}
322
328
else {
323
329
return (
324
330
< >
325
- < ResizeQRCode value = { connectionCode } level = { level } maxSize = { maxSize } marginTop = { marginTop } marginLeft = { marginLeft } />
331
+ < ResizeQRCode value = { codeContent } level = { level } maxSize = { maxSize } marginTop = { marginTop } marginLeft = { marginLeft } />
326
332
{ label }
327
333
</ >
328
334
) ;
0 commit comments