# MsgX: Message eXchange
This repository is **MsgX**, a message exchange interface to send binary data between languages, e.g., from C++ to Python. This is achived by serialising and deserialising native binary representation from some common interface.
This can be used as a *publisher* and *subscriber* model between C++ and Python, and a stateful model in the **Jupyter notebook** ecosystem that captures the incoming message. It supports asynchronous refresh within the notebook whenever a new message is published from your C++ files, and automatically display them within the notebook. This library also support non-notebook usage where it uses MsgX's native figure display from within your browser.
# Requirements
- zeromq (messaging protocol)
- capnproto (serialisation of message)
# Using the library in your C++ project
You can include the project it as you normally. The following shows a snippet to quickly visualise your code using MsgX without much setup
## Quick and dirty out-of-tree build in cmake
In your **CMakeLists.txt**:
```cmake
cmake_minimum_required(...)
...
# Add as out-of-tree build (with absolute path & binary directory)
add_subdirectory(
/home/soraxas/git-repo/msgx
msgx
)
find_package( msgx REQUIRED )
...
# link the library to your target
target_link_libraries( ${MY_TARGET} msgx )
```
# Example Usage
Say you have something like this in your `${MY_TARGET}`
```cpp
#include "msgx/message.h"
using namespace msgx::kwargs;
int main(int argc, char const *argv[]) {
msgx::MessageX msg;
std::vector<double> x{5, 2, 0, 4, 4, 6, 7};
std::vector<double> y{1, 2, 3, 2, 3, 4, 5};
msg = msg.Mapping("xs"_kw = x, "ys"_kw = y);
msg.send();
}
```
From python:
```python
>>> from msgx import spin_default
>>> spin_default()
# msg.send(); in c++
{'ys': array([1., 2., 3., 2., 3., 4., 5.]), 'xs': array([5., 2., 0., 4., 4., 6., 7.])}
```
Raw data
{
"_id": null,
"home_page": "https://github.com/soraxas/msgx",
"name": "msgx",
"maintainer": "",
"docs_url": null,
"requires_python": ">=3.5",
"maintainer_email": "",
"keywords": "msgx deserialise c++ capnp protobuf zmq",
"author": "Tin Lai (@soraxas)",
"author_email": "oscar@tinyiu.com",
"download_url": "https://files.pythonhosted.org/packages/eb/08/7667baa86210f0304bd8f9eebfd9629c57a24e2e3dbe05c326591b3f436c/msgx-1.0.3.tar.gz",
"platform": null,
"description": "# MsgX: Message eXchange\n\nThis repository is **MsgX**, a message exchange interface to send binary data between languages, e.g., from C++ to Python. This is achived by serialising and deserialising native binary representation from some common interface.\n\nThis can be used as a *publisher* and *subscriber* model between C++ and Python, and a stateful model in the **Jupyter notebook** ecosystem that captures the incoming message. It supports asynchronous refresh within the notebook whenever a new message is published from your C++ files, and automatically display them within the notebook. This library also support non-notebook usage where it uses MsgX's native figure display from within your browser.\n\n# Requirements\n\n- zeromq (messaging protocol)\n\n- capnproto (serialisation of message)\n\n# Using the library in your C++ project\n\nYou can include the project it as you normally. The following shows a snippet to quickly visualise your code using MsgX without much setup\n\n## Quick and dirty out-of-tree build in cmake\n\nIn your **CMakeLists.txt**:\n\n```cmake\ncmake_minimum_required(...)\n\n...\n\n# Add as out-of-tree build (with absolute path & binary directory)\nadd_subdirectory(\n /home/soraxas/git-repo/msgx\n msgx\n)\nfind_package( msgx REQUIRED )\n\n...\n\n# link the library to your target\ntarget_link_libraries( ${MY_TARGET} msgx )\n```\n\n# Example Usage\n\nSay you have something like this in your `${MY_TARGET}`\n\n```cpp\n#include \"msgx/message.h\"\n\nusing namespace msgx::kwargs;\n\nint main(int argc, char const *argv[]) {\n msgx::MessageX msg;\n std::vector<double> x{5, 2, 0, 4, 4, 6, 7};\n std::vector<double> y{1, 2, 3, 2, 3, 4, 5};\n\n msg = msg.Mapping(\"xs\"_kw = x, \"ys\"_kw = y);\n msg.send();\n}\n```\nFrom python:\n```python\n>>> from msgx import spin_default\n>>> spin_default()\n\n# msg.send(); in c++\n\n{'ys': array([1., 2., 3., 2., 3., 4., 5.]), 'xs': array([5., 2., 0., 4., 4., 6., 7.])}\n```\n\n",
"bugtrack_url": null,
"license": "MIT",
"summary": "Message Exchange protocol.",
"version": "1.0.3",
"project_urls": {
"Homepage": "https://github.com/soraxas/msgx"
},
"split_keywords": [
"msgx",
"deserialise",
"c++",
"capnp",
"protobuf",
"zmq"
],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "b26a9cc3a71cc64995f0e62b84493bfdcdec91056080ded15e57fd6294228559",
"md5": "6f24b859d66b6f2b34ae117211efde6d",
"sha256": "fa789b5484c4ab0617bb68e6e65f0adc03e2d247f391dc22ed639cc5812aa9e8"
},
"downloads": -1,
"filename": "msgx-1.0.3-py3-none-any.whl",
"has_sig": false,
"md5_digest": "6f24b859d66b6f2b34ae117211efde6d",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": ">=3.5",
"size": 11832,
"upload_time": "2024-01-15T03:46:56",
"upload_time_iso_8601": "2024-01-15T03:46:56.567554Z",
"url": "https://files.pythonhosted.org/packages/b2/6a/9cc3a71cc64995f0e62b84493bfdcdec91056080ded15e57fd6294228559/msgx-1.0.3-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "eb087667baa86210f0304bd8f9eebfd9629c57a24e2e3dbe05c326591b3f436c",
"md5": "dfccf11c90288a3bb096918afda2ca3e",
"sha256": "94e4822a15b973dcbe6f93522fe09f4d7dd97283d13c79ac84b4793b4b12fd88"
},
"downloads": -1,
"filename": "msgx-1.0.3.tar.gz",
"has_sig": false,
"md5_digest": "dfccf11c90288a3bb096918afda2ca3e",
"packagetype": "sdist",
"python_version": "source",
"requires_python": ">=3.5",
"size": 10014,
"upload_time": "2024-01-15T03:46:58",
"upload_time_iso_8601": "2024-01-15T03:46:58.581442Z",
"url": "https://files.pythonhosted.org/packages/eb/08/7667baa86210f0304bd8f9eebfd9629c57a24e2e3dbe05c326591b3f436c/msgx-1.0.3.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2024-01-15 03:46:58",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "soraxas",
"github_project": "msgx",
"travis_ci": false,
"coveralls": false,
"github_actions": false,
"lcname": "msgx"
}