UNPKG

@microsoft/windows-admin-center-sdk

Version:

Microsoft - Windows Admin Center Shell

27 lines (25 loc) 1.2 kB
import { from, zip } from 'rxjs'; import { map } from 'rxjs/operators'; import { RpcOutboundClient } from '../rpc-outbound-client'; import { RpcForwardDownKey } from './rpc-forward-model'; import { RpcForwardUpClient } from './rpc-forward-up-client'; export class RpcForwardAutoClient { /** * report a forward update from the shell or module */ static forward(rpc, data) { if (!rpc.isShell) { return RpcForwardUpClient.forward(rpc, data); } // If we are the shell, then broadcast forwards to all iframes // since only gateway, connections, and auth services use this architecture, it should be safe. return zip(...rpc.rpcManager.getCurrentRpcOutbound() .map(rpcOutbound => from(RpcOutboundClient.callOutbound(rpc.rpcManager.rpcChannel, rpcOutbound, RpcForwardDownKey.command, RpcForwardDownKey.version, data)))) .pipe(map(results => { // TODO: do we care about errors from other frames? return results.find(rpcOutbound => rpcOutbound === rpc.rpcManager.rpcOutbound) || results[0]; })) .toPromise(); } } //# sourceMappingURL=rpc-forward-auto-client.js.map