in lib/connection.ts [55:79]
onMessageListener(e: MessageEvent) {
const data = e.data;
const {allowedSenderOrigin} = this.options;
if (allowedSenderOrigin && e.origin !== allowedSenderOrigin && !isIE11) {
return;
}
if (data.type === TYPE_RESPONSE) {
this.popCallback(data.callId, data.success, data.result);
} else if (data.type === TYPE_MESSAGE) {
this
.callLocalApi(data.methodName, data.arguments)
.then(res => this.responseOtherSide(data.callId, res))
.catch(err => this.responseOtherSide(data.callId, err, false));
} else if (data.type === TYPE_SET_INTERFACE) {
this.setInterface(data.apiMethods);
this.responseOtherSide(data.callId);
} else if (data.type === TYPE_SERVICE_MESSAGE) {
this
.callLocalServiceMethod(data.methodName, data.arguments)
.then(res => this.responseOtherSide(data.callId, res))
.catch(err => this.responseOtherSide(data.callId, err, false));
}
}