Skip to content

Commit 24f42e4

Browse files
Mohit TejaniMohit Tejani
authored andcommitted
set enableEventEngine to true, restore flag to true by default,
fix titanium test to equate expected operation type
1 parent 8da3dca commit 24f42e4

File tree

4 files changed

+20
-11
lines changed

4 files changed

+20
-11
lines changed

src/core/interfaces/configuration.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ const USE_SSL = true;
2323
/**
2424
* Whether PubNub client should catch up subscription after network issues.
2525
*/
26-
const RESTORE = false;
26+
const RESTORE = true;
2727

2828
/**
2929
* Whether network availability change should be announced with `PNNetworkDownCategory` and
@@ -49,7 +49,7 @@ const FILE_PUBLISH_RETRY_LIMIT = 5;
4949
/**
5050
* Whether subscription event engine should be used or not.
5151
*/
52-
const ENABLE_EVENT_ENGINE = false;
52+
const ENABLE_EVENT_ENGINE = true;
5353

5454
/**
5555
* Whether configured user presence state should be maintained by the PubNub client or not.
@@ -250,7 +250,7 @@ export type UserConfiguration = {
250250
/**
251251
* `true` to allow catch up on the front-end applications.
252252
*
253-
* @default `false`
253+
* @default `true`
254254
*/
255255
restore?: boolean;
256256

@@ -303,7 +303,7 @@ export type UserConfiguration = {
303303
* param description in this table.
304304
*
305305
*
306-
* @default `false`
306+
* @default `true`
307307
*/
308308
enableEventEngine?: boolean;
309309

src/event-engine/states/handshaking.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,7 @@ HandshakingState.on(handshakeSuccess.type, (context, { payload }) =>
7777
category: categoryConstants.PNConnectedCategory,
7878
affectedChannels: context.channels.slice(0),
7979
affectedChannelGroups: context.groups.slice(0),
80+
operation: RequestOperation.PNSubscribeOperation,
8081
currentTimetoken: !!context.cursor?.timetoken ? context.cursor?.timetoken : payload.timetoken,
8182
}),
8283
],

src/event-engine/states/receiving.ts

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,7 @@ ReceivingState.on(subscriptionChange.type, (context, { payload }) => {
7676
category: !payload.isOffline
7777
? categoryConstants.PNDisconnectedCategory
7878
: categoryConstants.PNDisconnectedUnexpectedlyCategory,
79+
operation: RequestOperation.PNUnsubscribeOperation,
7980
...(errorCategory ? { error: errorCategory } : {}),
8081
}),
8182
]);
@@ -136,7 +137,10 @@ ReceivingState.on(receiveFailure.type, (context, { payload }) =>
136137
ReceivingState.on(disconnect.type, (context, event) => {
137138
if (!event.payload.isOffline) {
138139
return ReceiveStoppedState.with({ ...context }, [
139-
emitStatus({ category: categoryConstants.PNDisconnectedCategory }),
140+
emitStatus({
141+
category: categoryConstants.PNDisconnectedCategory,
142+
operation: RequestOperation.PNUnsubscribeOperation,
143+
}),
140144
]);
141145
} else {
142146
const errorReason = PubNubAPIError.create(new Error('Network connection error')).toPubNubError(
@@ -146,12 +150,18 @@ ReceivingState.on(disconnect.type, (context, event) => {
146150
return ReceiveFailedState.with({ ...context, reason: errorReason }, [
147151
emitStatus({
148152
category: categoryConstants.PNDisconnectedUnexpectedlyCategory,
153+
operation: RequestOperation.PNUnsubscribeOperation,
149154
error: errorReason.status?.category,
150155
}),
151156
]);
152157
}
153158
});
154159

155160
ReceivingState.on(unsubscribeAll.type, (_) =>
156-
UnsubscribedState.with(undefined, [emitStatus({ category: categoryConstants.PNDisconnectedCategory })]),
161+
UnsubscribedState.with(undefined, [
162+
emitStatus({
163+
category: categoryConstants.PNDisconnectedCategory,
164+
operation: RequestOperation.PNUnsubscribeOperation,
165+
}),
166+
]),
157167
);

test/dist/web-titanium.test.js

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -150,9 +150,7 @@ describe('#distribution test (titanium)', function () {
150150
});
151151

152152
it('should have to unsubscribe', function (done) {
153-
pubnub.disconnect();
154-
pubnub.removeListener(listener);
155-
pubnub.reconnect();
153+
pubnub.subscribe({ channels: [myChannel1] });
156154

157155
var finished = false;
158156

@@ -171,6 +169,6 @@ describe('#distribution test (titanium)', function () {
171169
}
172170
},
173171
});
174-
pubnub.unsubscribe({ channels: [myChannel1] });
172+
pubnub.unsubscribeAll();
175173
});
176-
});
174+
});

0 commit comments

Comments
 (0)