How to fire the backend event?

Now my frontend can subsribe the events emit from the backend, but my question is how can i fire the backend events? Should my backend starts a http server and listens on a port?

You can refer to JsonRpcServer based file system implementation here:

  1. packages/filesystem/src/common/filesystem.ts - the interface declarations
  2. packages/filesystem/src/node/node-filesystem.ts - the file system implementation in the backend
  3. setClient(...) method in FileSystemNode - this method sets the client that needs to receive the notification
  4. interface FileSystemClient is the interface the client on the frontend needs to implement.
  5. Frontend client needs to call setClient to register itself as a client that receives notifications from backend.
  6. Refer to FileSystemWatcher in packages/filesystem/src/browser/filesystem-watcher.ts where it calls the following:
            /* ... */
  1. The following code in FileSystemNode backend is an example of how the notification can be sent to frontend:
    this.client.onWillMove(sourceUri, targetUri); or this.client.onDidMove(sourceUri, targetUri);

Hope this helps.


OK i try it later, thank you very much.