mirror of
https://github.com/lubosz/overte.git
synced 2025-08-07 19:21:16 +02:00
more safeguards to help diagnose broken EventBridges
This commit is contained in:
parent
3d7676e918
commit
9d4f9b0a4b
2 changed files with 13 additions and 6 deletions
|
@ -88,12 +88,16 @@ try {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
function onEventBridgeOpened(eventBridge) {
|
function onEventBridgeOpened(_eventBridge) {
|
||||||
EventBridge = eventBridge;
|
if (!window.EventBridge) {
|
||||||
log('openEventBridge.opened', EventBridge);
|
window.EventBridge = _eventBridge;
|
||||||
|
}
|
||||||
|
assert(_eventBridge === window.EventBridge,
|
||||||
|
'ERROR: window.EventBridge materialized spontaneously and differently from the QWebChannel-derived value');
|
||||||
|
log('openEventBridge.opened', window.EventBridge);
|
||||||
|
|
||||||
bridgedSettings = new BridgedSettings({
|
bridgedSettings = new BridgedSettings({
|
||||||
eventBridge: EventBridge,
|
eventBridge: window.EventBridge,
|
||||||
namespace: PARAMS.namespace,
|
namespace: PARAMS.namespace,
|
||||||
uuid: PARAMS.uuid,
|
uuid: PARAMS.uuid,
|
||||||
debug: PARAMS.debug,
|
debug: PARAMS.debug,
|
||||||
|
@ -114,7 +118,7 @@ try {
|
||||||
|
|
||||||
debugPrint('>>> SENDING ACK');
|
debugPrint('>>> SENDING ACK');
|
||||||
// let Client script know we are ready
|
// let Client script know we are ready
|
||||||
eventBridge.emitWebEvent(location.href);
|
bridgedSettings.eventBridge.emitWebEvent(location.href);
|
||||||
|
|
||||||
function onValueReceived(key, value, oldValue, origin) {
|
function onValueReceived(key, value, oldValue, origin) {
|
||||||
onMutationEvent.paused++;
|
onMutationEvent.paused++;
|
||||||
|
|
|
@ -239,12 +239,15 @@ function BrowserUtils(global) {
|
||||||
// this.log('openEventBridge| EventBridge already exists... -- invoking callback', 'typeof EventBridge == ' + typeof global.EventBridge);
|
// this.log('openEventBridge| EventBridge already exists... -- invoking callback', 'typeof EventBridge == ' + typeof global.EventBridge);
|
||||||
return callback(global.EventBridge);
|
return callback(global.EventBridge);
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
this.log('EventBridge does not yet exist -- attempting to instrument via qt.webChannelTransport');
|
this.log('EventBridge does not yet exist in a usable state -- attempting to instrument via qt.webChannelTransport',
|
||||||
|
Object.keys(global.EventBridge));
|
||||||
var QWebChannel = assert(global.QWebChannel, 'expected global.QWebChannel to exist'),
|
var QWebChannel = assert(global.QWebChannel, 'expected global.QWebChannel to exist'),
|
||||||
qt = assert(global.qt, 'expected global.qt to exist');
|
qt = assert(global.qt, 'expected global.qt to exist');
|
||||||
assert(qt.webChannelTransport, 'expected global.qt.webChannelTransport to exist');
|
assert(qt.webChannelTransport, 'expected global.qt.webChannelTransport to exist');
|
||||||
new QWebChannel(qt.webChannelTransport, bind(this, function (channel) {
|
new QWebChannel(qt.webChannelTransport, bind(this, function (channel) {
|
||||||
var objects = channel.objects;
|
var objects = channel.objects;
|
||||||
|
assert(!global.EventBridge, '... global.EventBridge was unavailable at page load, but has unexpectedly materialized; ' +
|
||||||
|
Object.keys(global.EventBridge));
|
||||||
global.EventBridge = objects.eventBridge || (objects.eventBridgeWrapper && objects.eventBridgeWrapper.eventBridge);
|
global.EventBridge = objects.eventBridge || (objects.eventBridgeWrapper && objects.eventBridgeWrapper.eventBridge);
|
||||||
assert(global.EventBridge, '!global.EventBridge');
|
assert(global.EventBridge, '!global.EventBridge');
|
||||||
global.EventBridge.$WebChannel = channel;
|
global.EventBridge.$WebChannel = channel;
|
||||||
|
|
Loading…
Reference in a new issue