Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

#96 #94 Cleanup and refactor client-server communication #73

Merged
merged 3 commits into from
Aug 25, 2020

Conversation

tortmayr
Copy link
Contributor

Part of:

- Refactor client-server communication into a base protocol and a jsonrpc specific implementation (#94)
- Cleanup protocol and implement (previously unused) shutdown method
- Add ClientSessionManager to track lifecycle of GLSP client connections (#96)
- Add listener-mechanism to react to lifecycle changes (used in 
DefaultModelStateProvider)
- Remove (now obsolete) GLSPClientProxyProvider
- Fix wrong version of guava in org.eclipse.glsp.graph pom.xml
- Add unique applicationId to InitializeParameters

Part of:
- eclipse-glsp/glsp/issues/94
- eclipse-glsp/glsp/issues/96
tortmayr added a commit to eclipse-glsp/glsp-examples that referenced this pull request Aug 24, 2020
-Update dependencies to conform to sprotty 0.9.0 and Theia 1.3.0
- Adapt code to confrom to client/server changes
- Change argument for passing the server port to "WF_GLSP"

Requires: 
- eclipse-glsp/glsp-server/pull/73
- eclipse-glsp/glsp-theia-integration/pull/44

Part of:
- eclipse-glsp/glsp/issues/104
- eclipse-glsp/glsp/issues/94
- eclipse-glsp/glsp/issues/96
- eclipse-glsp/glsp/issues/105
@tortmayr tortmayr requested a review from planger August 24, 2020 13:44
@tortmayr
Copy link
Contributor Author

tortmayr commented Aug 24, 2020

@CamilleLetavernier Could you have a look at the ClientSessionMananger? Does it provide everything you need in terms of lifecycle managment?

Copy link
Member

@CamilleLetavernier CamilleLetavernier left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The ClientSessionMananger seems to provide everything we need; however I have some concerns about the clientId/GLSPClient mapping (See comments in line)


boolean removeListener(ClientSessionListener listener);

Optional<GLSPClient> resolve(String clientId);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this reliable? If I understand correctly, 1 GLSPClient corresponds to one "tab" in a browser, and 1 client ID corresponds to one "Widget" in a tab. So if we have 2 different GLSPClients, they may use the same clientId (Typically, xxx-diagram_0_widget). Since (AFAIU) the ClientSessionManager is shared across multiple modules, we can't assume that clientId will be unique ids (They are only unique for 1 GLSPClient / injection Module)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Each client application ("tab") now generates a unique applicaitonId that is also part of the clientId/widgetId.
(https://github.com/eclipse-glsp/glsp-theia-integration/blob/6fa15d9a0c374af2f5aa641884d880d84b70b08a/src/browser/diagram/glsp-diagram-manager.ts#L75)
This ensures that client ids are unique even when multiple actual clients are connected.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, great! Then it looks good to me :)


private final Set<GLSPClient> clients = new HashSet<>();
private final Set<ClientSessionListener> listeners = new LinkedHashSet<>();
private final Map<String, GLSPClient> clientSessions = new HashMap<>();
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this doesn't work with the way clientIds are currently generated

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Works because I adapted the way that clientIds are generated. They are now unique for each actual client/application

Copy link
Member

@CamilleLetavernier CamilleLetavernier left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I didn't test the changes; but the ClientSessionManager API looks good to me. I'll have to test that in real application to see if notifications are properly sent in all cases (Especially, I didn't see how/if the server can trigger disconnectClient when the connection is lost. I'm not sure that's even desired; e.g. if the client can reconnect using the same app/client Id without reloading the tab)

Copy link
Member

@planger planger left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great work, thanks a lot!
I've appended a few minor changes in a separate commit for your review. Other than that, this looks great!
Just a general remark regarding copyrights, please keep the original where applicable but just update the year (e.g. original 2019 --> now 2019 - 2020).

/*******************************************************************************
* Copyright (c) 2019 EclipseSource and others.
/********************************************************************************
* Copyright (c) 2020 EclipseSource and others.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this actually should then be 2019 - 2020 ....

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In general you are right. But you picked a bad example. The DisposeClientAction was introduced with this commit so the copyright year should be 2020. This is displayed weirdly because Github is diffing GLSPClientAware <-> DisposeClientAction

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I did not touch any existing copyright headers in this PR

@tortmayr tortmayr merged commit c58cdef into master Aug 25, 2020
@tortmayr tortmayr deleted the tortmayr/lifecycle branch August 25, 2020 07:32
tortmayr added a commit to eclipse-glsp/glsp-examples that referenced this pull request Aug 25, 2020
* #105 #104 #96 #94 #39 Refactor client-server communication

-Update dependencies to conform to sprotty 0.9.0 and Theia 1.3.0
- Adapt code to confrom to client/server changes
- Change argument for passing the server port to "WF_GLSP"

Requires: 
- eclipse-glsp/glsp-server/pull/73
- eclipse-glsp/glsp-theia-integration/pull/44

Part of:
- eclipse-glsp/glsp/issues/104
- eclipse-glsp/glsp/issues/94
- eclipse-glsp/glsp/issues/96
- eclipse-glsp/glsp/issues/105

* Update launch config to changed env args

* Adapt copyright headers

* Update versions

Co-authored-by: Philip Langer <planger@eclipsesource.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants