Theia: How to communicate with the backend in Authoring Theia Extensions.

Created on 16 Jul 2019  ·  6Comments  ·  Source: eclipse-theia/theia

Description

I am creating an extension with reference to Authoring Theia Extensions, Json-Rpc and Complete example in Json-Rpc Docs.
I added a menu and when I select that menu I want to call the backend using json-rpc, but it does not get called.
The server object variable I was calling was empty.
In my case, I used WorkspaceServer in my backend server code.

And I do not know how to add 'services / *' to the webpack.config.js file.
After I edit the file, I build it as 'yarn' and all of my changes disappear.
Uploading image.png…

Is there any additional documentation or source code example that I can refer to to solve this problem?

question

All 6 comments

Can you share your code?

@kittaakos Share the source code here.

In my case, I used WorkspaceServer in my backend server code.

Why the WorkspaceServer? What do you want to do? I thought you want to create a service that is implemented on the backend and be able to call this service (via JSON-RPC) from the frontend? Is this what you want to achieve?

@kittaakos I use WorkspaceServer because I refer to other source codes like that @theia/core, and there is no other reason.
I just want to test server side code.

What I want to do is get the server side environment variables and pass them to the client(frontend).
And I want to do REST-API processing on the server site and pass the result to the client(frontend).

I use WorkspaceServer because I refer to other source codes like that @theia/core, and there is no other reason.

OK. So if I got this correctly, it is not a must to use the WorkspaceService.

I just want to test server side code.

👍
I have created a PR with the changes of a simple RPC service example: https://github.com/wonjooncho/theia-backend/pull/1

screencast 2019-07-16 11-07-17

And I want to do REST-API processing on the server site and pass the result to the client(frontend).

You will need a cutom BackendApplicationContribution for this. In the configure(app: express.Application) method you register your backend REST endpint. Check for an express example. For instance, here: https://www.codementor.io/wapjude/creating-a-simple-rest-api-with-expressjs-in-5min-bbtmk51mq.

I hope this helps.

@kittaakos Thanks for your help.
It works.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

Beetix picture Beetix  ·  3Comments

vince-fugnitto picture vince-fugnitto  ·  3Comments

akosyakov picture akosyakov  ·  3Comments

jankeromnes picture jankeromnes  ·  3Comments

kpge picture kpge  ·  3Comments