-
Notifications
You must be signed in to change notification settings - Fork 0
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
Create a WebSocket backend #1
Comments
Mini DocumentationThe protocol is evolving but here's a mini documentation of the way it currently works. The front and back-ends communicate by exchanging JSON objects. Each communication consists of a request sent by the front-end and a corresponding reply by the back-end. Below are some cookbook examples. Setting a variable: {'set': 'p1', 'value': {'first': 'John', 'last': 'Doe', 'age': 30}}
{'result': 'success'} Getting a variable: {'get': 'p1'}
{'result': 'success', 'return': {'first': 'John', 'last': 'Doe', 'age': 30}} Errors: {'get': 'p2'}
{'result': 'error', 'description': 'no such variable'} Calls: {'call': 'square', 'args': {'x': 5}}
{'result': 'success', 'return': 25} Evaluation: {'eval': 'square(5)'}
{'result': 'success', 'return': '25\n'} Exceptions: {'eval': 'hello world'}
{'result': 'exception', 'return': ' File "<console>", line 1\n hello world\n ^\nSyntaxError: invalid syntax\n'} Notes
|
@gtarawneh Thanks for the mini documentation! It's mostly clear, but I've got a few questions/comments:
Perhaps, you can set up a working document for the API specification somewhere so we could discuss it and work out details together? |
@snowleopard some follow-up points:
At the moment,
Aha, yes that sounds reasonable. I'll simplify things and just merge the two concepts into
Yes I agree this would help, and this is definitely something we should do at some point. But let's keep it fluid for the time being, because I'm still exploring some options in terms of API design.
Sure, I'll add this to the repo as a starting point. |
We need to figure out a way to connect Centrifuge to the frontend that @gtarawneh is developing.
The backend will need to interact with the frontend by handling requests of the following types:
Eval(e)
: given an expressione
evaluate it in the server-side scope and send the result as a response.Get(name)
is a simple special case: lookup a value byname
, i.e. evaluate the expressionname
.Bind(name, e)
: bind a name to an expression and send an acknowledgement.There may be some variants of the above, where we might also want to return any diagnostic output produced when executing the above requests, so it can be shown to the user. @gtarawneh Perhaps, you could add a small example of such an interactive session?
Some useful links:
The text was updated successfully, but these errors were encountered: