Currently, CommWidget provides basic communication in both directions:
A widget inheriting from CommWidget can send messages to the clients (for client in self._clients: client.send().)
A widget inheriting from CommWidget can receive messages which call back into its list of self._commands.
There are some problems with this approach:
A message from the server to the client waits for an ACK to unblock the communication channel. This is a good idea for the time-series application but in other circumstances we do not want this. Instead we want messages without a return value and messages with an asynchronous return value (that's what the ACK is currently.)
A message from the client to the server does not allow any ACK or return value yet.
Sending a message from the client to the server is not exposed in the Vue component exported by comm.js yet.
The interface we would like to see (on the Python side.):
Let's suppose that we want to query the client for a half edge, i.e., the user should click on one and that is returned to the server.
We cannot send that query to all clients as is, since we would have to cancel all these queries once a click happened in one frontend. So instead, we need to perform this query with a cancellation token that is somehow hidden away on the client. Then the server can invoke this cancellation token once any of the clients responds. This means that CommWidget can implement send as for client in clients: send but needs to implement query differently to supporte:
requests = self.query(...)
await any of requests
for request in requests: request.cancel()
So we can use it to solve https://github.com/flatsurf/ipyvue-flatsurf/issues/35.
Currently,
CommWidget
provides basic communication in both directions:CommWidget
can send messages to the clients (for client in self._clients: client.send()
.)CommWidget
can receive messages which call back into its list ofself._commands
.There are some problems with this approach:
comm.js
yet.The interface we would like to see (on the Python side.):
And the same on the JavaScript side.
A Basic Use Case
Let's suppose that we want to query the client for a half edge, i.e., the user should click on one and that is returned to the server.
We cannot send that query to all clients as is, since we would have to cancel all these queries once a click happened in one frontend. So instead, we need to perform this query with a cancellation token that is somehow hidden away on the client. Then the server can invoke this cancellation token once any of the clients responds. This means that
CommWidget
can implementsend
asfor client in clients: send
but needs to implementquery
differently to supporte: