Engine Web
The web engine provides a connector for Iframe & Websocket.
npm install @remixproject/engine-web
Iframe
The iframe connector is used to load & connect a plugin inside an iframe.
Iframe based plugin are webview using an index.html
as entry point & need to use @remixproject/plugin-iframe
.
const myPlugin = new IframePlugin({
name: 'my-plugin',
url: 'https://my-plugin-path.com',
methods: ['getData']
})
engine.register(myPlugin);
await manager.activatePlugin('my-plugin');
const data = manager.call('my-plugin', 'getData');
Communication between the plugin & the engine uses the window.postMessage()
API.
Websocket
The websocket connector wraps the native Websocket object from the Web API.
Websocket based plugin are usually server with a Websocket connection open. Any library can be used, remixproject provide a wrapper around the ws
library : @remixproject/plugin-ws
.
const myPlugin = new WebsocketOptions({
name: 'my-plugin',
url: 'https://my-server.com',
methods: ['getData']
}, {
reconnectDelay: 5000
});
engine.register(myPlugin);
await manager.activatePlugin('my-plugin');
const data = manager.call('my-plugin', 'getData');