sinch-rtc
Version:
RTC JavaScript/Web SDK
49 lines • 1.94 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.DefaultNotificationResult = void 0;
const fsm_1 = require("../session/fsm");
const PushPayload_1 = require("./PushPayload");
class DefaultNotificationResult {
constructor(payload, notificationDisplayName) {
this.notificationDisplayName = notificationDisplayName;
this.valid = false;
this.valid = !payload
? false
: PushPayload_1.PushPayload.tryDecode(payload, (message) => {
this.message = message;
});
}
isValid() {
return this.valid;
}
get displayName() {
return this.notificationDisplayName;
}
get callNotificationResult() {
if (!this.valid || !this.message)
throw new fsm_1.InvalidOperationError("Cannot return CallNotificationResult for non-valid push notification.");
return {
callId: this.message.sessionId,
remoteUserId: this.message.userId,
isVideoOffered: () => this.isFlagSet(DefaultNotificationResult.VIDEO_OFFERED_FLAG),
hasTimedOut: () => {
return this.message
? new Date().getTime() - this.message.timestamp.getTime() >
DefaultNotificationResult.PUSH_TIMEOUT_MS
: false;
},
headers: this.message.publicHeaders,
domain: this.message.domain,
};
}
isFlagSet(flag) {
var _a, _b;
if ((_a = this.message) === null || _a === void 0 ? void 0 : _a.flags)
return (((_b = this.message) === null || _b === void 0 ? void 0 : _b.flags) & flag) != 0;
return false;
}
}
exports.DefaultNotificationResult = DefaultNotificationResult;
DefaultNotificationResult.VIDEO_OFFERED_FLAG = 0x01;
DefaultNotificationResult.PUSH_TIMEOUT_MS = 60000;
//# sourceMappingURL=DefaultNotificationResult.js.map