iTwin / itwinjs-core

Monorepo for iTwin.js Library
https://www.itwinjs.org
MIT License
615 stars 210 forks source link

Ipc interface implementation on web app example #1967

Closed kardoka closed 3 years ago

kardoka commented 3 years ago

Hi, I have tried to implement an Ipc interface using the example code on this page on top of the iTwin viewer web app tutorial "Adding showcase widgets to your iTwin Viewer" (https://developer.bentley.com/tutorials/adding-showcase-widgets-to-your-itwin-viewer). The code in the iTwin viewer tutorial does not have back-end code, so I cannot use the IpcHandler.

What are my options for implementing a working Ipc interface for a iTwin viewer? Should I instead use the archived Electron example, which has a distinguished backend? (https://github.com/imodeljs/imodeljs-samples/tree/master/interactive-app/simple-viewer-app/src)


⚠ Do not edit this section. It is required for imodeljs.github.io ➟ GitHub issue linking

pmconne commented 3 years ago

I believe the desktop-starter is the right template for your use case. It has its own very minimalist backend that you could add to. @kckst8 can provide more information.

aruniverse commented 3 years ago

Did you mean your own RPC not IPC?

If you did mean to write and use an IPC, then yea you will need to use a desktop/electron app. If you meant to write and use your own RPC, then you need your own backend and can point to it from your iTwin web viewer.

Either way to start off I'd recommend using the desktop-viewer template over the desktop-starter. The desktop-viewer uses a very similar Viewer component as found in the web viewer for the frontend so you can easily copy your web app code to it. It also has a local backend, which it will automatically point to and you can use to register both your own IPCs and RPCs.

Follow the Create Application steps here to create your desktop app and copy your client ID that looks like native-XXXXXXXXXXXXXXXXXXX and add it to the .env

kardoka commented 3 years ago

Everything works now, thanks!