Skip to content

Commit 6cced93

Browse files
Mohit TejaniMohit Tejani
authored andcommitted
update emit event, when disconnect called to include operation
1 parent 8dbe69a commit 6cced93

5 files changed

Lines changed: 29 additions & 6 deletions

File tree

dist/web/pubnub.js

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9307,6 +9307,7 @@
93079307
category: StatusCategory$1.PNConnectedCategory,
93089308
affectedChannels: context.channels.slice(0),
93099309
affectedChannelGroups: context.groups.slice(0),
9310+
operation: RequestOperation$1.PNSubscribeOperation,
93109311
currentTimetoken: !!((_d = context.cursor) === null || _d === void 0 ? void 0 : _d.timetoken) ? (_e = context.cursor) === null || _e === void 0 ? void 0 : _e.timetoken : payload.timetoken,
93119312
}),
93129313
]);
@@ -9510,20 +9511,29 @@
95109511
var _a;
95119512
if (!event.payload.isOffline) {
95129513
return ReceiveStoppedState.with(Object.assign({}, context), [
9513-
emitStatus({ category: StatusCategory$1.PNDisconnectedCategory }),
9514+
emitStatus({
9515+
category: StatusCategory$1.PNDisconnectedCategory,
9516+
operation: RequestOperation$1.PNUnsubscribeOperation,
9517+
}),
95149518
]);
95159519
}
95169520
else {
95179521
const errorReason = PubNubAPIError.create(new Error('Network connection error')).toPubNubError(RequestOperation$1.PNSubscribeOperation);
95189522
return ReceiveFailedState.with(Object.assign(Object.assign({}, context), { reason: errorReason }), [
95199523
emitStatus({
95209524
category: StatusCategory$1.PNDisconnectedUnexpectedlyCategory,
9525+
operation: RequestOperation$1.PNUnsubscribeOperation,
95219526
error: (_a = errorReason.status) === null || _a === void 0 ? void 0 : _a.category,
95229527
}),
95239528
]);
95249529
}
95259530
});
9526-
ReceivingState.on(unsubscribeAll.type, (_) => UnsubscribedState.with(undefined, [emitStatus({ category: StatusCategory$1.PNDisconnectedCategory })]));
9531+
ReceivingState.on(unsubscribeAll.type, (_) => UnsubscribedState.with(undefined, [
9532+
emitStatus({
9533+
category: StatusCategory$1.PNDisconnectedCategory,
9534+
operation: RequestOperation$1.PNUnsubscribeOperation,
9535+
}),
9536+
]));
95279537

95289538
/**
95299539
* Subscribe Event Engine effects dispatcher.

dist/web/pubnub.min.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

lib/event-engine/states/handshaking.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@ exports.HandshakingState.on(events_1.handshakeSuccess.type, (context, { payload
5656
category: categories_1.default.PNConnectedCategory,
5757
affectedChannels: context.channels.slice(0),
5858
affectedChannelGroups: context.groups.slice(0),
59+
operation: operations_1.default.PNSubscribeOperation,
5960
currentTimetoken: !!((_d = context.cursor) === null || _d === void 0 ? void 0 : _d.timetoken) ? (_e = context.cursor) === null || _e === void 0 ? void 0 : _e.timetoken : payload.timetoken,
6061
}),
6162
]);

lib/event-engine/states/receiving.js

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -90,17 +90,26 @@ exports.ReceivingState.on(events_1.disconnect.type, (context, event) => {
9090
var _a;
9191
if (!event.payload.isOffline) {
9292
return receive_stopped_1.ReceiveStoppedState.with(Object.assign({}, context), [
93-
(0, effects_1.emitStatus)({ category: categories_1.default.PNDisconnectedCategory }),
93+
(0, effects_1.emitStatus)({
94+
category: categories_1.default.PNDisconnectedCategory,
95+
operation: operations_1.default.PNUnsubscribeOperation,
96+
}),
9497
]);
9598
}
9699
else {
97100
const errorReason = pubnub_api_error_1.PubNubAPIError.create(new Error('Network connection error')).toPubNubError(operations_1.default.PNSubscribeOperation);
98101
return receive_failed_1.ReceiveFailedState.with(Object.assign(Object.assign({}, context), { reason: errorReason }), [
99102
(0, effects_1.emitStatus)({
100103
category: categories_1.default.PNDisconnectedUnexpectedlyCategory,
104+
operation: operations_1.default.PNUnsubscribeOperation,
101105
error: (_a = errorReason.status) === null || _a === void 0 ? void 0 : _a.category,
102106
}),
103107
]);
104108
}
105109
});
106-
exports.ReceivingState.on(events_1.unsubscribeAll.type, (_) => unsubscribed_1.UnsubscribedState.with(undefined, [(0, effects_1.emitStatus)({ category: categories_1.default.PNDisconnectedCategory })]));
110+
exports.ReceivingState.on(events_1.unsubscribeAll.type, (_) => unsubscribed_1.UnsubscribedState.with(undefined, [
111+
(0, effects_1.emitStatus)({
112+
category: categories_1.default.PNDisconnectedCategory,
113+
operation: operations_1.default.PNUnsubscribeOperation,
114+
}),
115+
]));

src/event-engine/states/receiving.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,10 @@ ReceivingState.on(receiveFailure.type, (context, { payload }) =>
136136
ReceivingState.on(disconnect.type, (context, event) => {
137137
if (!event.payload.isOffline) {
138138
return ReceiveStoppedState.with({ ...context }, [
139-
emitStatus({ category: categoryConstants.PNDisconnectedCategory }),
139+
emitStatus({
140+
category: categoryConstants.PNDisconnectedCategory,
141+
operation: RequestOperation.PNUnsubscribeOperation,
142+
}),
140143
]);
141144
} else {
142145
const errorReason = PubNubAPIError.create(new Error('Network connection error')).toPubNubError(

0 commit comments

Comments
 (0)