機械翻訳について

UEFによるVB間の外部通信

カスタム・イベントを使用して、VBでiFrameからiFrameへの通信を有効にできます。 この通信チャネルを有効にするには、カスタム・イベントを定義する必要があります。

これを行うには、外部アプリケーションがイベントをリスニングし、カスタム・イベントのサブスクリプションを追加する必要があります。 このイベントは、別の外部アプリケーションから公開できます。 イベント・サブスクリプションおよびイベント公開アクションは、この通信を容易にするために、同じイベント名(customEventName)の同じコンテキストで発生する必要があります。

ノート: グローバル・コンテキストのカスタム・イベント・サブスクリプションは、同じカスタム・イベント(同じcustomEventName)のパブリッシュがglobalContextで発生した場合にのみリスニングされます。 ブラウザtabContextやrecordContextなど、異なるコンテキスト上で同じイベントの公開リクエストが発生した場合、イベント通知は受信されません。

customEventName (myEvent1)のCustomEventを介した外部アプリケーション通信の例

外部アプリケーション1にカスタム・イベント・サブスクリプションを追加し、同じTabContextの上に外部アプリケーション2から同じイベントを公開するTypeScriptの例を次に示します。

//Call the below method from External Application - 1
const subscribeCustomEvent = async () => {
    const payload: ICustomEventSubscriptionRequest = uiEventsFrameworkInstance.requestHelper.createSubscriptionRequest('cxEventBusCustomEvent') as ICustomEventSubscriptionRequest;
    payload.setCustomEventName('myEvent1');
    const tabContext: ITabContext = await uiEventsFrameworkInstance.getTabContext('browserTabId');
    tabContext.subscribe(payload, (message: IEventResponse) => {
        const response: ICustomEventSubscriptionResponse = message as ICustomEventSubscriptionResponse;
        console.log(response.getResponseData());
        console.log(response.getResponseData().getData()); // { message: 'any data' }
        console.log(response.getResponseData().getCustomEventName()) // 'myEvent1'
    });
};

// Call the below method from External Application - 2
const publishCustomEvent = async () => {
    const payload: ICustomEventRequest = uiEventsFrameworkInstance.requestHelper.createPublishRequest('CustomEvent') as ICustomEventRequest;
    payload.setCustomEventName('myEvent1');
    payload.setEventPayload({ message: 'any data' });
    const tabContext: ITabContext = await uiEventsFrameworkInstance.getTabContext('browserTabId');
    tabContext.publish(payload).then((message: IOperationResponse) => {
    }).catch((err) => {
        console.log(err);
    });
};

外部アプリケーション1にカスタム・イベント・サブスクリプションを追加し、同じTabContextの上に外部アプリケーション2から同じイベントを公開するJavaScriptの例を次に示します。

//Call the below method from External Application - 1
const subscribeCustomEvent = async () => {
    const payload = uiEventsFrameworkInstance.requestHelper.createSubscriptionRequest('cxEventBusCustomEvent');
    payload.setCustomEventName('myEvent1');
    const tabContext = await uiEventsFrameworkInstance.getTabContext('browserTabId');
    tabContext.subscribe(payload, (message) => {
        const response = message;
        console.log(response.getResponseData());
        console.log(response.getResponseData().getData()); // { message: 'any data' }
        console.log(response.getResponseData().getCustomEventName()) // 'myEvent1'
    });
};

// Call the below method from External Application - 2
const publishCustomEvent = async () => {
    const payload = uiEventsFrameworkInstance.requestHelper.createPublishRequest('CustomEvent');
    payload.setCustomEventName('myEvent1');
    payload.setEventPayload({ message: 'any data' });
    const tabContext = await uiEventsFrameworkInstance.getTabContext('browserTabId');
    tabContext.publish(payload).then((message) => {
    }).catch((err) => {
        console.log(err);
    });
};