Skip to content

Commit e73bcda

Browse files
committed
notifying application when a connection is denied
1 parent ae7aa0c commit e73bcda

File tree

2 files changed

+14
-5
lines changed

2 files changed

+14
-5
lines changed

index.d.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@ export interface GlobalInputData {
5252
isError: boolean;
5353
isDisconnected: boolean;
5454
isConnected: boolean;
55+
isConnectionDenied: boolean;
5556
initData: InitData;
5657
senders: Sender[];
5758
sendValue: SendValueFunction;

src/globalinput.js

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,8 @@ const ACTION_TYPES = {
1313
CONNECTION_ERROR: 7,
1414
RECEIVED_FIELD: 8,
1515
SEND_FIELD: 9,
16-
CLOSE: 10
16+
CLOSE: 10,
17+
CONNECTION_DENIED:11
1718
};
1819

1920
const MobileState = {
@@ -33,6 +34,7 @@ export const initialState = {
3334
isError: false,
3435
isDisconnected: false,
3536
isConnected: false,
37+
isConnectionDenied:false,
3638
initData: null,
3739
connected: []
3840
};
@@ -214,6 +216,7 @@ const buildMobileConfig = (initData, options, notify) => {
214216
else {
215217
if (mobileData.sender && mobileData.sender.client !== permissionMessage.client) {
216218
deny(" only one sender (mobile app instance) is allowed for each session. You need to restart the session to allow for a new client to connect. If you are the application developer, you can override this behaviour.");
219+
notify({ type: ACTION_TYPES.CONNECTION_DENIED });
217220
}
218221
else {
219222
allow();
@@ -272,22 +275,27 @@ export const reducer = (state, action) => {
272275
switch (action.type) {
273276
case ACTION_TYPES.START_CONNECT:
274277
case ACTION_TYPES.SEND_INIT_DATA:
275-
state = { ...state, errorMessage: '', field: null };
278+
state = { ...state, errorMessage: '', field: null, isConnectionDenied: false };
276279
break;
277280
case ACTION_TYPES.REGISTERED:
278-
state = { ...state, errorMessage: '', field: null, connectionCode: action.connectionCode };
281+
state = { ...state, errorMessage: '', field: null, connectionCode: action.connectionCode, isConnectionDenied: false };
279282
break;
280283
case ACTION_TYPES.RECEIVED_FIELD:
281-
state = { ...state, field: action.field };
284+
state = { ...state, field: action.field, isConnectionDenied: false };
282285
break;
283286
case ACTION_TYPES.CONNECTION_ERROR:
284287
case ACTION_TYPES.REGISTER_FAILED:
285-
state = { ...state, errorMessage: action.errorMessage };
288+
state = { ...state, errorMessage: action.errorMessage, isConnectionDenied: false };
289+
break;
290+
case ACTION_TYPES.CONNECTION_DENIED:
291+
state = { ...state, isConnectionDenied: true };
286292
break;
287293
case ACTION_TYPES.SENDER_CONNECTED:
288294
case ACTION_TYPES.SENDER_DISCONNECTED:
289295
case ACTION_TYPES.SEND_FIELD:
290296
case ACTION_TYPES.CLOSE:
297+
state = { ...state, isConnectionDenied: false };
298+
break;
291299
default:
292300
};
293301
return {

0 commit comments

Comments
 (0)