This repository has been archived by the owner on Oct 10, 2024. It is now read-only.
Harmony: server and javascript improvements #211
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Changes
This PR changes how javascript functions are processed in Harmony and improves on socket server used for communication between python and Harmony.
Javascript changes
All code running inside Harmony is now seperated from Python code and reside in
js
folder in its own files. ESlint is configured there via node.js to help with development if needed. Just runnpm install
inside js directory to get everything set up. If your favorite IDE supports ESlint, it should pick up its configuration with all globals and style codes.After avalon is installed in host, it will read
AvalonHarmony.js
and send it directly to Harmony.AvalonHarmony
is javascript namespace containing all functions called by Avalon API. Too add new function, just add it toAvalonHarmony
namespace like:and call it from Python like:
you can also pass:
and that will pass whole script file to Harmony and evaluate it in global scope.
Server changes
Server/client now uses stricter protocol to handle communication. This was necessary because there was no precise control over data passed between server/client. Now, each message is prepended with 6 bytes:
First two bytes are magic bytes stands for Avalon Harmony. Next four bytes hold length of the message
...
encoded as 32bit unsigned integer. This way we know how many bytes to read from the socket and if we need more or we need to parse multiple messages.Related
Python code was changed to be more Python 3 like.