Engine Web
The web engine provides a connector for Iframe & Websocket.
npm install @remix-project/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 @remix-project/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, remix-project provide a wrapper around the ws library : @remix-project/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');