eclipsesource / graphical-lsp

Graphical language server platform for building web-based diagram editors
https://www.eclipse.org/glsp
Eclipse Public License 2.0
36 stars 8 forks source link

Clarify how client diagrams can be uniquely identified on the server-side #301

Closed CamilleLetavernier closed 4 years ago

CamilleLetavernier commented 5 years ago

Clients are expected to attach a client-ID to the messages they send to the server. However, when the server sends a message directly to a client, we also expect a clientId, to know which model/diagram is affected (See #297)

The problem is that, outside of messages sent by the client, the server doesn't really know about clientIds (It is generated on the client side when loading a new model). The clientId is also stored in the graphicalModelState (Immediately upon loading the model?).

ClientIds are also unique only per-client, so to identify one specific diagram in a multi-client scenario, we need the (GLSPClient, clientId) pair (Or (GLSPServer, clientId), since, if I'm not mistaken, there is a 1-1 mapping between GLSPServer and GLSPClient)

Currently, in #297, we work around this issue by storing the clientId - to - clientProxy mapping when receiving a message from the client (typically the LoadModelAction), but that's not ideal.

The point of this ticket is to clarify how diagrams should be uniquely identified from the server point of view, when sending a message from the server to the client, and adapt DefaultGLSPServer, GLSPClientProvider and DIActionDispatcher accordingly.

This might be part of a larger issue to scope the various providers/services: do we expect all server services to be unique and manage all diagrams and all diagrams (Using unique IDs to identify each client), or should we consider scoping the injection for each GSLPClient, or even each (GLSPClient, clientId) pair? (i.e. each loaded model)