Kitware / visualizer

The ParaViewWeb Visualizer application which can be used standalone or as a component within another web context.
https://kitware.github.io/visualizer/
BSD 3-Clause "New" or "Revised" License
115 stars 28 forks source link

Provide option to set `sessionURL` in pvw-visualizer.py #95

Closed phcerdan closed 3 years ago

phcerdan commented 3 years ago

Hi there @jourdain, instead of providing --content ./dist, I would like the pvw-visualizer.py to listen to client from another port for development purposes (hot reload). I think the option is named sessionURL (inferred from the Vue example here),

    WS_CONNECT({ state, commit, dispatch }) {
      // Initiate network connection
      const config = { application: 'cone' };

      // Custom setup for development (http:8080 / ws:1234)
      if (location.port === '8080') {
        // We suppose that we have dev server and that ParaView/VTK is running on port 1234
        config.sessionURL = `ws://${location.hostname}:1234/ws`;
      }

How can I hack passing sessionURL to the server through pvw-visualizer.py?

jourdain commented 3 years ago

I'm not sure to follow, but sessionURL is what the client use to connect to a running pvw process. So nothing to do with pvw-visualizer.py.

If you want to start pvw-visualizer.py on demand from the client, then you need to use the launcher.

phcerdan commented 3 years ago

I understand, thanks @jourdain. I thought it would be possible to avoid using a launcher, as in https://github.com/Kitware/web-project-templates/tree/master/vue-vtkjs-pvw-template, when using port 8080 for the client, and port 1234 for the pvw-server (the defaults).

$ npm run serve &
$ /.../pvpython ./server/pvpython/pvw-server.py --port 1234

Open your browser to http://localhost:8080/
phcerdan commented 3 years ago

Well, you can really hack adding config.sessionURL = 'ws://localhost:1234/ws'; to connect here.

export function connect(config = {}) {
  loading();
  config.sessionURL = 'ws://localhost:1234/ws'; // <------- HACK TODO for development
  network.onReady(start);
  network.onError(loading);
  network.onClose(() => loading('Server disconnected'));
  network.connect(config);

  // Configure renderer to local if asked for
  if (config.renderer) {
    dispatch(actions.view.setRemoteRendering(config.renderer === 'remote'));
  }
}
jourdain commented 3 years ago

Or you can pass it in the url by relaying on this and that